change to asserting malloc

This commit is contained in:
~hatteb-mitlyd 2014-04-01 17:47:01 -07:00
parent 974b37a9c0
commit a0c18f56b2
15 changed files with 116 additions and 102 deletions

View File

@ -83,7 +83,7 @@ u2_cf_path(c3_c* top_c,
c3_w top_w = strlen(top_c); c3_w top_w = strlen(top_c);
c3_w len_w = _cf_path_1(0, (top_w + 1), tah); c3_w len_w = _cf_path_1(0, (top_w + 1), tah);
c3_w buf_w = len_w + (ext_c ? (1 + strlen(ext_c)) : 0); c3_w buf_w = len_w + (ext_c ? (1 + strlen(ext_c)) : 0);
c3_c* buf_c = malloc(buf_w + 1); c3_c* buf_c = c3_malloc(buf_w + 1);
c3_w pos_w; c3_w pos_w;
u2_noun pas; u2_noun pas;
@ -162,7 +162,7 @@ u2_cf_flat_load(u2_noun mod,
} }
fln_w = sat_s.st_size; fln_w = sat_s.st_size;
fil_c = malloc(sat_s.st_size); fil_c = c3_malloc(sat_s.st_size);
if ( fln_w != read(fid_i, fil_c, fln_w) ) { if ( fln_w != read(fid_i, fil_c, fln_w) ) {
return u2_none; return u2_none;
@ -238,7 +238,7 @@ u2_cf_flat_save(u2_noun mod,
} }
fln_w = u2_met(3, som); fln_w = u2_met(3, som);
fil_y = malloc(fln_w); fil_y = c3_malloc(fln_w);
u2_cr_bytes(0, fln_w, fil_y, som); u2_cr_bytes(0, fln_w, fil_y, som);
u2_cz(som); u2_cz(som);
@ -301,7 +301,7 @@ c3_c*
u2_cr_string(u2_atom a) u2_cr_string(u2_atom a)
{ {
c3_w met_w = u2_cr_met(3, a); c3_w met_w = u2_cr_met(3, a);
c3_c* str_c = malloc(met_w + 1); c3_c* str_c = c3_malloc(met_w + 1);
u2_cr_bytes(0, met_w, (c3_y*)str_c, a); u2_cr_bytes(0, met_w, (c3_y*)str_c, a);
str_c[met_w] = 0; str_c[met_w] = 0;
@ -319,7 +319,7 @@ u2_cr_tape(u2_noun a)
for ( i_w = 0, b=a; u2_yes == u2du(b); i_w++, b=u2t(b) ) for ( i_w = 0, b=a; u2_yes == u2du(b); i_w++, b=u2t(b) )
; ;
a_y = malloc(i_w + 1); a_y = c3_malloc(i_w + 1);
for ( i_w = 0, b=a; u2_yes == u2du(b); i_w++, b=u2t(b) ) { for ( i_w = 0, b=a; u2_yes == u2du(b); i_w++, b=u2t(b) ) {
a_y[i_w] = u2h(b); a_y[i_w] = u2h(b);
@ -361,7 +361,7 @@ u2_ci_chubs(c3_w a_w,
{ {
// XX considerably suboptimal // XX considerably suboptimal
{ {
c3_w *b_w = malloc(a_w * 8); c3_w *b_w = c3_malloc(a_w * 8);
c3_w i_w; c3_w i_w;
u2_atom p; u2_atom p;

View File

@ -153,7 +153,7 @@ _cs_save(u2_ho_cash* cas_s,
void* qtr_v = per_p->ptr_v; void* qtr_v = per_p->ptr_v;
u2_ho_cash* cax_s; u2_ho_cash* cax_s;
if ( 0 == (cax_s = malloc(sizeof(*cax_s))) ) { if ( 0 == (cax_s = c3_malloc(sizeof(*cax_s))) ) {
return; return;
} }
_cs_init(cax_s); _cs_init(cax_s);
@ -349,7 +349,7 @@ u2_ho_cstring(u2_noun xip) // retain
c3_w len_w = _ho_mop_chip(0, xip); c3_w len_w = _ho_mop_chip(0, xip);
c3_c *cos_c; c3_c *cos_c;
if ( !(cos_c = malloc(len_w + 1)) ) abort(); if ( !(cos_c = c3_malloc(len_w + 1)) ) abort();
_ho_mop_chip(cos_c, xip); _ho_mop_chip(cos_c, xip);
cos_c[len_w] = 0; cos_c[len_w] = 0;
@ -385,7 +385,7 @@ _ho_down(u2_ho_hangar *hag)
void void
u2_ho_push(void) u2_ho_push(void)
{ {
u2_ho_hangar *hag = malloc(sizeof(u2_ho_hangar)); u2_ho_hangar *hag = c3_malloc(sizeof(u2_ho_hangar));
_ho_boot(hag); _ho_boot(hag);
hag->nex_h = u2_HostHangar; hag->nex_h = u2_HostHangar;
@ -531,13 +531,13 @@ _ho_explore_dummy(u2_rail ral_r,
{ {
u2_ho_driver *dry_d; u2_ho_driver *dry_d;
if ( !(dry_d = malloc(sizeof(u2_ho_driver))) ) { if ( !(dry_d = c3_malloc(sizeof(u2_ho_driver))) ) {
abort(); abort();
} }
dry_d->cos_c = cos_c; dry_d->cos_c = cos_c;
dry_d->sub_d = 0; dry_d->sub_d = 0;
dry_d->xip = xip; dry_d->xip = xip;
if ( !(dry_d->fan_j = malloc(sizeof(u2_ho_jet))) ) { if ( !(dry_d->fan_j = c3_malloc(sizeof(u2_ho_jet))) ) {
abort(); abort();
} }
dry_d->fan_j->fcs_c = 0; dry_d->fan_j->fcs_c = 0;

View File

@ -164,7 +164,7 @@ u2_ux_read(u2_ray wir_r,
} }
fln_w = sat_s.st_size; fln_w = sat_s.st_size;
fil_c = malloc(sat_s.st_size); fil_c = c3_malloc(sat_s.st_size);
if ( fln_w != read(fid_i, fil_c, fln_w) ) { if ( fln_w != read(fid_i, fil_c, fln_w) ) {
return u2_none; return u2_none;
@ -240,7 +240,7 @@ u2_ux_write(u2_wire wir_r,
return u2_no; return u2_no;
} }
fln_w = u2_met(3, som); fln_w = u2_met(3, som);
fil_y = malloc(fln_w); fil_y = c3_malloc(fln_w);
u2_bytes(0, fln_w, fil_y, som); u2_bytes(0, fln_w, fil_y, som);
if ( fln_w != write(fid_i, fil_y, fln_w) ) { if ( fln_w != write(fid_i, fil_y, fln_w) ) {

View File

@ -71,7 +71,7 @@
{ {
c3_w i_w; c3_w i_w;
loc_u->hev = malloc(u2_ckb_lent(u2k(hev)) * sizeof(u2_noun)); loc_u->hev = c3_malloc(u2_ckb_lent(u2k(hev)) * sizeof(u2_noun));
for ( i_w = 0; u2_nul != hev; i_w++ ) { for ( i_w = 0; u2_nul != hev; i_w++ ) {
loc_u->hev[i_w] = u2h(hev); loc_u->hev[i_w] = u2h(hev);
@ -80,7 +80,7 @@
loc_u->lev_w = i_w; loc_u->lev_w = i_w;
} }
loc_u->kct_w = 0; loc_u->kct_w = 0;
loc_u->kad = malloc( loc_u->kad = c3_malloc(
(1 + c3_min(loc_u->lev_w, loc_u->lel_w)) * (1 + c3_min(loc_u->lev_w, loc_u->lel_w)) *
sizeof(u2_noun)); sizeof(u2_noun));

View File

@ -20,7 +20,7 @@
u2_atom a) // retain u2_atom a) // retain
{ {
c3_w met_w = u2_met(3, a); c3_w met_w = u2_met(3, a);
c3_y* fat_y = malloc(met_w + 1); c3_y* fat_y = c3_malloc(met_w + 1);
u2_bytes(0, met_w, fat_y, a); u2_bytes(0, met_w, fat_y, a);
{ {
@ -51,7 +51,7 @@
u2_atom b) // retain u2_atom b) // retain
{ {
c3_assert(u2_fly_is_cat(a)); c3_assert(u2_fly_is_cat(a));
c3_y* fat_y = malloc(a + 1); c3_y* fat_y = c3_malloc(a + 1);
u2_bytes(0, a, fat_y, b); u2_bytes(0, a, fat_y, b);
{ {

View File

@ -88,3 +88,7 @@
} \ } \
cnt_w = (cnt_w + 1) % (n); \ cnt_w = (cnt_w + 1) % (n); \
} while (0) } while (0)
/* c3_malloc(): asserting malloc
*/
void*
c3_malloc(size_t s);

View File

@ -28,7 +28,7 @@
static uv_buf_t static uv_buf_t
_ames_alloc(uv_handle_t* had_u, size_t len_i) _ames_alloc(uv_handle_t* had_u, size_t len_i)
{ {
void* ptr_v = malloc(len_i); void* ptr_v = c3_malloc(len_i);
// uL(fprintf(uH, "grab %p\n", ptr_v)); // uL(fprintf(uH, "grab %p\n", ptr_v));
return uv_buf_init(ptr_v, len_i); return uv_buf_init(ptr_v, len_i);
@ -181,7 +181,7 @@ u2_ames_ef_send(u2_noun lan, u2_noun pac)
if ( u2_yes == _ames_lane_ip(lan, &por_s, &pip_w) ) { if ( u2_yes == _ames_lane_ip(lan, &por_s, &pip_w) ) {
c3_w len_w = u2_cr_met(3, pac); c3_w len_w = u2_cr_met(3, pac);
c3_y* buf_y = malloc(len_w); c3_y* buf_y = c3_malloc(len_w);
u2_cr_bytes(0, len_w, buf_y, pac); u2_cr_bytes(0, len_w, buf_y, pac);
@ -200,7 +200,7 @@ u2_ames_ef_send(u2_noun lan, u2_noun pac)
if ( 0 != pip_w ) { if ( 0 != pip_w ) {
uv_buf_t buf_u = uv_buf_init((c3_c*)buf_y, len_w); uv_buf_t buf_u = uv_buf_init((c3_c*)buf_y, len_w);
_u2_udp_send_t* ruq_u = malloc(sizeof(_u2_udp_send_t)); _u2_udp_send_t* ruq_u = c3_malloc(sizeof(_u2_udp_send_t));
ruq_u->buf_y = buf_y; ruq_u->buf_y = buf_y;

View File

@ -47,7 +47,7 @@
static uv_buf_t static uv_buf_t
_cttp_alloc(uv_handle_t* had_u, size_t len_i) _cttp_alloc(uv_handle_t* had_u, size_t len_i)
{ {
return uv_buf_init(malloc(len_i), len_i); return uv_buf_init(c3_malloc(len_i), len_i);
} }
/* _cttp_bod(): create a data buffer. /* _cttp_bod(): create a data buffer.
@ -55,7 +55,7 @@ _cttp_alloc(uv_handle_t* had_u, size_t len_i)
static u2_hbod* static u2_hbod*
_cttp_bod(c3_w len_w, const c3_y* hun_y) _cttp_bod(c3_w len_w, const c3_y* hun_y)
{ {
u2_hbod* bod_u = malloc(len_w + sizeof(*bod_u)); u2_hbod* bod_u = c3_malloc(len_w + sizeof(*bod_u));
bod_u->len_w = len_w; bod_u->len_w = len_w;
memcpy(bod_u->hun_y, hun_y, len_w); memcpy(bod_u->hun_y, hun_y, len_w);
@ -72,7 +72,7 @@ _cttp_bud(c3_c* nam_c, c3_c* val_c)
c3_w lnm_w = strlen(nam_c); c3_w lnm_w = strlen(nam_c);
c3_w lvl_w = strlen(val_c); c3_w lvl_w = strlen(val_c);
c3_w len_w = lnm_w + 2 + lvl_w + 2; c3_w len_w = lnm_w + 2 + lvl_w + 2;
u2_hbod* bod_u = malloc(len_w + sizeof(*bod_u)); u2_hbod* bod_u = c3_malloc(len_w + sizeof(*bod_u));
strncpy((c3_c *)bod_u->hun_y, nam_c, lnm_w); strncpy((c3_c *)bod_u->hun_y, nam_c, lnm_w);
strncpy((c3_c *)bod_u->hun_y + lnm_w, ": ", 2); strncpy((c3_c *)bod_u->hun_y + lnm_w, ": ", 2);
@ -145,7 +145,7 @@ _cttp_bods_to_octs(u2_hbod* bod_u)
len_w += bid_u->len_w; len_w += bid_u->len_w;
} }
} }
buf_y = malloc(len_w); buf_y = c3_malloc(len_w);
{ {
c3_y* ptr_y = buf_y; c3_y* ptr_y = buf_y;
@ -171,7 +171,7 @@ _cttp_heds_list(u2_hhed* hed_u, u2_noun nam, u2_noun vaz)
while ( u2_nul != viz ) { while ( u2_nul != viz ) {
u2_hhed* deh_u; u2_hhed* deh_u;
deh_u = malloc(sizeof(*deh_u)); deh_u = c3_malloc(sizeof(*deh_u));
deh_u->nam_c = u2_cr_string(nam); deh_u->nam_c = u2_cr_string(nam);
deh_u->val_c = u2_cr_string(u2h(viz)); deh_u->val_c = u2_cr_string(u2h(viz));
@ -222,7 +222,7 @@ _cttp_octs_to_bod(u2_noun oct)
len_w = u2h(oct); len_w = u2h(oct);
{ {
u2_hbod* bod_u = malloc(len_w + sizeof(*bod_u)); u2_hbod* bod_u = c3_malloc(len_w + sizeof(*bod_u));
bod_u->len_w = len_w; bod_u->len_w = len_w;
u2_cr_bytes(0, len_w, bod_u->hun_y, u2t(oct)); u2_cr_bytes(0, len_w, bod_u->hun_y, u2t(oct));
@ -414,7 +414,7 @@ static c3_c*
_cttp_creq_url(u2_noun pul) _cttp_creq_url(u2_noun pul)
{ {
c3_w len_w = _cttp_mcut_url(0, 0, u2k(pul)); c3_w len_w = _cttp_mcut_url(0, 0, u2k(pul));
c3_c* url_c = malloc(len_w + 1); c3_c* url_c = c3_malloc(len_w + 1);
_cttp_mcut_url(url_c, 0, pul); _cttp_mcut_url(url_c, 0, pul);
url_c[len_w] = 0; url_c[len_w] = 0;
@ -428,7 +428,7 @@ static c3_c*
_cttp_creq_host(u2_noun hot) _cttp_creq_host(u2_noun hot)
{ {
c3_w len_w = _cttp_mcut_host(0, 0, u2k(hot)); c3_w len_w = _cttp_mcut_host(0, 0, u2k(hot));
c3_c* hot_c = malloc(len_w + 1); c3_c* hot_c = c3_malloc(len_w + 1);
_cttp_mcut_host(hot_c, 0, hot); _cttp_mcut_host(hot_c, 0, hot);
hot_c[len_w] = 0; hot_c[len_w] = 0;
@ -508,7 +508,7 @@ static c3_c*
_cttp_more(c3_c* str_c, const c3_c* buf_c, size_t siz_i) _cttp_more(c3_c* str_c, const c3_c* buf_c, size_t siz_i)
{ {
if ( !str_c ) { if ( !str_c ) {
str_c = malloc(siz_i + 1); str_c = c3_malloc(siz_i + 1);
memcpy(str_c, buf_c, siz_i); memcpy(str_c, buf_c, siz_i);
str_c[siz_i] = 0; str_c[siz_i] = 0;
} }
@ -542,7 +542,7 @@ _cttp_header_field(http_parser* par_u, const c3_c* buf_c, size_t siz_i)
switch ( res_u->rat_e ) { switch ( res_u->rat_e ) {
case u2_hreq_non: case u2_hreq_non:
case u2_hreq_val: { case u2_hreq_val: {
u2_hhed* hed_u = malloc(sizeof(*hed_u)); u2_hhed* hed_u = c3_malloc(sizeof(*hed_u));
hed_u->nam_c = _cttp_more(0, buf_c, siz_i); hed_u->nam_c = _cttp_more(0, buf_c, siz_i);
hed_u->val_c = 0; hed_u->val_c = 0;
@ -662,12 +662,12 @@ static struct http_parser_settings _cttp_settings = {
static void static void
_cttp_cres_start(u2_creq* ceq_u) _cttp_cres_start(u2_creq* ceq_u)
{ {
u2_cres* res_u = malloc(sizeof(*res_u)); u2_cres* res_u = c3_malloc(sizeof(*res_u));
memset(res_u, 0, sizeof(*res_u)); memset(res_u, 0, sizeof(*res_u));
ceq_u->res_u = res_u; ceq_u->res_u = res_u;
res_u->par_u = malloc(sizeof(struct http_parser)); res_u->par_u = c3_malloc(sizeof(struct http_parser));
http_parser_init(res_u->par_u, HTTP_RESPONSE); http_parser_init(res_u->par_u, HTTP_RESPONSE);
((struct http_parser *)(res_u->par_u))->data = ceq_u; ((struct http_parser *)(res_u->par_u))->data = ceq_u;
@ -990,7 +990,7 @@ _cttp_ccon_kick_write_cryp(u2_ccon* coc_u)
static void static void
_cttp_ccon_kick_write_buf(u2_ccon* coc_u, uv_buf_t buf_u) _cttp_ccon_kick_write_buf(u2_ccon* coc_u, uv_buf_t buf_u)
{ {
_u2_write_t* ruq_u = (_u2_write_t*) malloc(sizeof(_u2_write_t)); _u2_write_t* ruq_u = (_u2_write_t*) c3_malloc(sizeof(_u2_write_t));
ruq_u->coc_u = coc_u; ruq_u->coc_u = coc_u;
ruq_u->buf_y = (c3_y*)buf_u.base; ruq_u->buf_y = (c3_y*)buf_u.base;
@ -1014,7 +1014,7 @@ _cttp_ccon_kick_write_body(u2_ccon* coc_u, u2_hbod *rub_u)
// XX extra copy here due to old code. Use hbod as base directly. // XX extra copy here due to old code. Use hbod as base directly.
// //
{ {
c3_y* buf_y = malloc(rub_u->len_w + 1); c3_y* buf_y = c3_malloc(rub_u->len_w + 1);
memcpy(buf_y, rub_u->hun_y, rub_u->len_w); memcpy(buf_y, rub_u->hun_y, rub_u->len_w);
buf_y[rub_u->len_w] = 0; buf_y[rub_u->len_w] = 0;
@ -1051,7 +1051,7 @@ _cttp_ccon_cryp_rout(u2_ccon* coc_u)
c3_i bur_i; c3_i bur_i;
{ {
c3_y* buf_y = malloc(1<<14); c3_y* buf_y = c3_malloc(1<<14);
while ( 0 < (bur_i = BIO_read(coc_u->ssl.wio_u, buf_y, 1<<14)) ) { while ( 0 < (bur_i = BIO_read(coc_u->ssl.wio_u, buf_y, 1<<14)) ) {
buf_u = uv_buf_init((c3_c*)buf_y, bur_i); buf_u = uv_buf_init((c3_c*)buf_y, bur_i);
_cttp_ccon_kick_write_buf(coc_u, buf_u); _cttp_ccon_kick_write_buf(coc_u, buf_u);
@ -1298,7 +1298,7 @@ _cttp_ccon_kick(u2_ccon* coc_u)
static u2_ccon* static u2_ccon*
_cttp_ccon_new(u2_bean sec, c3_s por_s, c3_c* hot_c) _cttp_ccon_new(u2_bean sec, c3_s por_s, c3_c* hot_c)
{ {
u2_ccon* coc_u = malloc(sizeof(u2_ccon)); u2_ccon* coc_u = c3_malloc(sizeof(u2_ccon));
memset(coc_u, 0, sizeof(u2_ccon)); memset(coc_u, 0, sizeof(u2_ccon));
@ -1354,7 +1354,7 @@ _cttp_ccon(u2_bean sec, c3_s por_s, c3_c* hot_c)
static u2_creq* static u2_creq*
_cttp_creq_new(c3_l num_l, u2_noun hes) _cttp_creq_new(c3_l num_l, u2_noun hes)
{ {
u2_creq* ceq_u = malloc(sizeof(u2_creq)); u2_creq* ceq_u = c3_malloc(sizeof(u2_creq));
u2_noun pul = u2h(hes); u2_noun pul = u2h(hes);
u2_noun hat = u2h(pul); u2_noun hat = u2h(pul);
u2_noun sec = u2h(hat); u2_noun sec = u2h(hat);

View File

@ -31,7 +31,7 @@ static void _http_conn_dead(u2_hcon *hon_u);
static uv_buf_t static uv_buf_t
_http_alloc(uv_handle_t* had_u, size_t len_i) _http_alloc(uv_handle_t* had_u, size_t len_i)
{ {
return uv_buf_init(malloc(len_i), len_i); return uv_buf_init(c3_malloc(len_i), len_i);
} }
/* _http_bod(): create a data buffer. /* _http_bod(): create a data buffer.
@ -39,7 +39,7 @@ _http_alloc(uv_handle_t* had_u, size_t len_i)
static u2_hbod* static u2_hbod*
_http_bod(c3_w len_w, const c3_y* hun_y) _http_bod(c3_w len_w, const c3_y* hun_y)
{ {
u2_hbod* bod_u = malloc(len_w + sizeof(*bod_u)); u2_hbod* bod_u = c3_malloc(len_w + sizeof(*bod_u));
bod_u->len_w = len_w; bod_u->len_w = len_w;
memcpy(bod_u->hun_y, hun_y, len_w); memcpy(bod_u->hun_y, hun_y, len_w);
@ -56,7 +56,7 @@ _http_bud(c3_c* nam_c, c3_c* val_c)
c3_w lnm_w = strlen(nam_c); c3_w lnm_w = strlen(nam_c);
c3_w lvl_w = strlen(val_c); c3_w lvl_w = strlen(val_c);
c3_w len_w = lnm_w + 2 + lvl_w + 2; c3_w len_w = lnm_w + 2 + lvl_w + 2;
u2_hbod* bod_u = malloc(len_w + sizeof(*bod_u)); u2_hbod* bod_u = c3_malloc(len_w + sizeof(*bod_u));
strncpy((c3_c *)bod_u->hun_y, nam_c, lnm_w); strncpy((c3_c *)bod_u->hun_y, nam_c, lnm_w);
strncpy((c3_c *)bod_u->hun_y + lnm_w, ": ", 2); strncpy((c3_c *)bod_u->hun_y + lnm_w, ": ", 2);
@ -150,7 +150,7 @@ _http_respond_buf(u2_hreq* req_u, uv_buf_t buf_u)
return; return;
} }
ruq_u = (_u2_write_t*) malloc(sizeof(_u2_write_t)); ruq_u = (_u2_write_t*) c3_malloc(sizeof(_u2_write_t));
ruq_u->buf_y = (c3_y*)buf_u.base; ruq_u->buf_y = (c3_y*)buf_u.base;
@ -175,7 +175,7 @@ _http_send_body(u2_hreq *req_u,
// XX extra copy here due to old code. Use hbod as base directly. // XX extra copy here due to old code. Use hbod as base directly.
// //
{ {
c3_y* buf_y = malloc(rub_u->len_w); c3_y* buf_y = c3_malloc(rub_u->len_w);
memcpy(buf_y, rub_u->hun_y, rub_u->len_w); memcpy(buf_y, rub_u->hun_y, rub_u->len_w);
buf_u = uv_buf_init((c3_c*)buf_y, rub_u->len_w); buf_u = uv_buf_init((c3_c*)buf_y, rub_u->len_w);
@ -350,7 +350,7 @@ static c3_c*
_http_more(c3_c* str_c, const c3_c* buf_c, size_t siz_i) _http_more(c3_c* str_c, const c3_c* buf_c, size_t siz_i)
{ {
if ( !str_c ) { if ( !str_c ) {
str_c = malloc(siz_i + 1); str_c = c3_malloc(siz_i + 1);
memcpy(str_c, buf_c, siz_i); memcpy(str_c, buf_c, siz_i);
str_c[siz_i] = 0; str_c[siz_i] = 0;
} }
@ -385,7 +385,7 @@ _http_header_field(http_parser* par_u, const c3_c* buf_c, size_t siz_i)
switch ( req_u->rat_e ) { switch ( req_u->rat_e ) {
case u2_hreq_non: case u2_hreq_non:
case u2_hreq_val: { case u2_hreq_val: {
u2_hhed* hed_u = malloc(sizeof(*hed_u)); u2_hhed* hed_u = c3_malloc(sizeof(*hed_u));
hed_u->nam_c = _http_more(0, buf_c, siz_i); hed_u->nam_c = _http_more(0, buf_c, siz_i);
hed_u->val_c = 0; hed_u->val_c = 0;
@ -508,7 +508,7 @@ static struct http_parser_settings _http_settings = {
static u2_hreq* static u2_hreq*
_http_req_new(u2_hcon* hon_u) _http_req_new(u2_hcon* hon_u)
{ {
u2_hreq* req_u = malloc(sizeof(*req_u)); u2_hreq* req_u = c3_malloc(sizeof(*req_u));
req_u->hon_u = hon_u; req_u->hon_u = hon_u;
req_u->seq_l = hon_u->seq_l++; req_u->seq_l = hon_u->seq_l++;
@ -516,7 +516,7 @@ _http_req_new(u2_hcon* hon_u)
req_u->met_e = (u2_hmet)0; req_u->met_e = (u2_hmet)0;
req_u->rat_e = (u2_hrat)0; req_u->rat_e = (u2_hrat)0;
req_u->par_u = malloc(sizeof(struct http_parser)); req_u->par_u = c3_malloc(sizeof(struct http_parser));
http_parser_init(req_u->par_u, HTTP_REQUEST); http_parser_init(req_u->par_u, HTTP_REQUEST);
((struct http_parser *)(req_u->par_u))->data = req_u; ((struct http_parser *)(req_u->par_u))->data = req_u;
@ -591,7 +591,7 @@ _http_conn_read_cb(uv_stream_t* tcp_u,
static void static void
_http_conn_new(u2_http *htp_u) _http_conn_new(u2_http *htp_u)
{ {
u2_hcon *hon_u = malloc(sizeof(*hon_u)); u2_hcon *hon_u = c3_malloc(sizeof(*hon_u));
uv_tcp_init(u2L, &hon_u->wax_u); uv_tcp_init(u2L, &hon_u->wax_u);
@ -707,7 +707,7 @@ _http_list_to_heds(u2_noun lix)
u2_noun pi_lix = u2h(i_lix); u2_noun pi_lix = u2h(i_lix);
u2_noun qi_lix = u2t(i_lix); u2_noun qi_lix = u2t(i_lix);
u2_noun t_lix = u2t(lix); u2_noun t_lix = u2t(lix);
u2_hhed* nex_u = malloc(sizeof(u2_hhed)); u2_hhed* nex_u = c3_malloc(sizeof(u2_hhed));
nex_u->nam_c = u2_cr_string(pi_lix); nex_u->nam_c = u2_cr_string(pi_lix);
nex_u->val_c = u2_cr_string(qi_lix); nex_u->val_c = u2_cr_string(qi_lix);
@ -738,7 +738,7 @@ _http_bods_to_octs(u2_hbod* bod_u)
len_w += bid_u->len_w; len_w += bid_u->len_w;
} }
} }
buf_y = malloc(len_w); buf_y = c3_malloc(len_w);
{ {
c3_y* ptr_y = buf_y; c3_y* ptr_y = buf_y;
@ -768,7 +768,7 @@ _http_octs_to_bod(u2_noun oct)
len_w = u2h(oct); len_w = u2h(oct);
{ {
u2_hbod* bod_u = malloc(len_w + sizeof(*bod_u)); u2_hbod* bod_u = c3_malloc(len_w + sizeof(*bod_u));
bod_u->len_w = len_w; bod_u->len_w = len_w;
u2_cr_bytes(0, len_w, bod_u->hun_y, u2t(oct)); u2_cr_bytes(0, len_w, bod_u->hun_y, u2t(oct));
@ -826,7 +826,7 @@ _http_new_response(c3_l sev_l, c3_l coq_l, c3_l seq_l, u2_noun rep)
return 0; return 0;
} }
else { else {
u2_hrep* rep_u = malloc(sizeof(u2_hrep)); u2_hrep* rep_u = c3_malloc(sizeof(u2_hrep));
rep_u->sev_l = sev_l; rep_u->sev_l = sev_l;
rep_u->coq_l = coq_l; rep_u->coq_l = coq_l;
@ -1021,7 +1021,7 @@ u2_http_io_init()
{ {
// Logically secure port. // Logically secure port.
{ {
u2_http *htp_u = malloc(sizeof(*htp_u)); u2_http *htp_u = c3_malloc(sizeof(*htp_u));
htp_u->sev_l = u2A->sev_l + 1; htp_u->sev_l = u2A->sev_l + 1;
htp_u->coq_l = 1; htp_u->coq_l = 1;
@ -1038,7 +1038,7 @@ u2_http_io_init()
// Insecure port. // Insecure port.
// //
{ {
u2_http *htp_u = malloc(sizeof(*htp_u)); u2_http *htp_u = c3_malloc(sizeof(*htp_u));
htp_u->sev_l = u2A->sev_l; htp_u->sev_l = u2A->sev_l;
htp_u->coq_l = 1; htp_u->coq_l = 1;

View File

@ -157,7 +157,7 @@ _main_getopt(c3_i argc, c3_c** argv)
fprintf(stderr, "$URBIT_HOME or $HOME must be set\n"); fprintf(stderr, "$URBIT_HOME or $HOME must be set\n");
exit(1); exit(1);
} else { } else {
u2_Host.ops_u.hom_c = malloc(hom_w + 1); u2_Host.ops_u.hom_c = c3_malloc(hom_w + 1);
snprintf(u2_Host.ops_u.hom_c, hom_w + 1, "%s/urbit", hom_c); snprintf(u2_Host.ops_u.hom_c, hom_w + 1, "%s/urbit", hom_c);
} }
} }
@ -180,7 +180,7 @@ _main_getopt(c3_i argc, c3_c** argv)
if ( u2_Host.ops_u.nam_c == 0 ) { if ( u2_Host.ops_u.nam_c == 0 ) {
c3_w len_w = sysconf(_SC_HOST_NAME_MAX) + 1; c3_w len_w = sysconf(_SC_HOST_NAME_MAX) + 1;
u2_Host.ops_u.nam_c = malloc(len_w); u2_Host.ops_u.nam_c = c3_malloc(len_w);
if ( 0 != gethostname(u2_Host.ops_u.nam_c, len_w) ) { if ( 0 != gethostname(u2_Host.ops_u.nam_c, len_w) ) {
perror("gethostname"); perror("gethostname");
exit(1); exit(1);
@ -256,6 +256,16 @@ static void _main_cont(void *arg1, void *arg2, void *arg3)
siglongjmp(Signal_buf, 1); siglongjmp(Signal_buf, 1);
} }
void*
c3_malloc(size_t s)
{
void* rut = malloc(s);
if ( u2_nul == rut ) {
c3_assert(!"memory lost");
}
return rut;
}
static void static void
overflow_handler(int emergency, stackoverflow_context_t scp) overflow_handler(int emergency, stackoverflow_context_t scp)
{ {

View File

@ -80,7 +80,7 @@ _raft_readname(const c3_c* str_c, c3_w siz_w)
c3_c* col_c; c3_c* col_c;
c3_w nam_w; c3_w nam_w;
nam_u->str_c = malloc(siz_w + 1); nam_u->str_c = c3_malloc(siz_w + 1);
strncpy(nam_u->str_c, str_c, siz_w); strncpy(nam_u->str_c, str_c, siz_w);
nam_u->str_c[siz_w] = '\0'; nam_u->str_c[siz_w] = '\0';
@ -91,7 +91,7 @@ _raft_readname(const c3_c* str_c, c3_w siz_w)
} }
else { else {
nam_w = col_c - nam_u->str_c + 1; nam_w = col_c - nam_u->str_c + 1;
nam_u->nam_c = malloc(nam_w); nam_u->nam_c = c3_malloc(nam_w);
uv_strlcpy(nam_u->nam_c, nam_u->str_c, nam_w); uv_strlcpy(nam_u->nam_c, nam_u->str_c, nam_w);
nam_u->por_c = strdup(col_c + 1); nam_u->por_c = strdup(col_c + 1);
} }
@ -143,7 +143,7 @@ u2_raft_readopt(const c3_c* arg_c, c3_c* our_c, c3_s oup_s)
static uv_buf_t static uv_buf_t
_raft_alloc(uv_handle_t* had_u, size_t siz_i) _raft_alloc(uv_handle_t* had_u, size_t siz_i)
{ {
uv_buf_t buf_u = { .base = malloc(siz_i), .len = siz_i }; uv_buf_t buf_u = { .base = c3_malloc(siz_i), .len = siz_i };
return buf_u; return buf_u;
} }
@ -497,7 +497,7 @@ _raft_rmsg_read(const u2_rbuf* buf_u, u2_rmsg* msg_u)
uL(fprintf(uH, "raft: length too short (e) %llu\n", msg_u->len_d)); uL(fprintf(uH, "raft: length too short (e) %llu\n", msg_u->len_d));
return -1; return -1;
} }
msg_u->rest.nam_c = malloc(4 * msg_u->rest.nam_w); msg_u->rest.nam_c = c3_malloc(4 * msg_u->rest.nam_w);
uv_strlcpy(msg_u->rest.nam_c, (const char*)(buf_u->buf_y + red_i), uv_strlcpy(msg_u->rest.nam_c, (const char*)(buf_u->buf_y + red_i),
4 * msg_u->rest.nam_w); 4 * msg_u->rest.nam_w);
red_i += 4 * msg_u->rest.nam_w; red_i += 4 * msg_u->rest.nam_w;
@ -539,7 +539,7 @@ _raft_rmsg_read(const u2_rbuf* buf_u, u2_rmsg* msg_u)
red_i = -1; red_i = -1;
goto fail; goto fail;
} }
ent_u[i_d].bob_w = malloc(4 * ent_u[i_d].len_w); ent_u[i_d].bob_w = c3_malloc(4 * ent_u[i_d].len_w);
memcpy(ent_u[i_d].bob_w, buf_u->buf_y + red_i, 4 * ent_u[i_d].len_w); memcpy(ent_u[i_d].bob_w, buf_u->buf_y + red_i, 4 * ent_u[i_d].len_w);
red_i += 4 * ent_u[i_d].len_w; red_i += 4 * ent_u[i_d].len_w;
} }
@ -567,7 +567,7 @@ static u2_rbuf*
_raft_rbuf_grow(u2_rbuf* buf_u, const c3_y* buf_y, size_t siz_i) _raft_rbuf_grow(u2_rbuf* buf_u, const c3_y* buf_y, size_t siz_i)
{ {
if ( 0 == buf_u ) { if ( 0 == buf_u ) {
buf_u = malloc(sizeof(*buf_u) + siz_i); buf_u = c3_malloc(sizeof(*buf_u) + siz_i);
buf_u->len_w = 0; buf_u->len_w = 0;
buf_u->cap_w = siz_i; buf_u->cap_w = siz_i;
} }
@ -751,10 +751,10 @@ _raft_conn_work(u2_rcon* ron_u)
if ( ron_u->wri_u && ron_u->wri_u->len_w > 0 ) { if ( ron_u->wri_u && ron_u->wri_u->len_w > 0 ) {
uv_buf_t buf_u; uv_buf_t buf_u;
struct _u2_write_t* req_u = malloc(sizeof(*req_u)); struct _u2_write_t* req_u = c3_malloc(sizeof(*req_u));
req_u->buf_y = malloc(ron_u->wri_u->len_w); req_u->buf_y = c3_malloc(ron_u->wri_u->len_w);
memcpy(req_u->buf_y, ron_u->wri_u->buf_y, ron_u->wri_u->len_w); memcpy(req_u->buf_y, ron_u->wri_u->buf_y, ron_u->wri_u->len_w);
buf_u.base = (char*)req_u->buf_y; buf_u.base = (char*)req_u->buf_y;
buf_u.len = ron_u->wri_u->len_w; buf_u.len = ron_u->wri_u->len_w;
@ -816,7 +816,7 @@ _raft_conn_read_cb(uv_stream_t* tcp_u,
static u2_rcon* static u2_rcon*
_raft_conn_new(u2_raft* raf_u) _raft_conn_new(u2_raft* raf_u)
{ {
u2_rcon* ron_u = malloc(sizeof(*ron_u)); u2_rcon* ron_u = c3_malloc(sizeof(*ron_u));
uv_tcp_init(u2L, &ron_u->wax_u); uv_tcp_init(u2L, &ron_u->wax_u);
ron_u->red_u = 0; ron_u->red_u = 0;
@ -863,9 +863,9 @@ _raft_remove_run(u2_rcon* ron_u)
static u2_rreq* static u2_rreq*
_raft_rreq_new(u2_rcon* ron_u) _raft_rreq_new(u2_rcon* ron_u)
{ {
u2_rreq* req_u = malloc(sizeof(*req_u)); u2_rreq* req_u = c3_malloc(sizeof(*req_u));
req_u->msg_u = malloc(sizeof(*req_u->msg_u)); req_u->msg_u = c3_malloc(sizeof(*req_u->msg_u));
req_u->nex_u = 0; req_u->nex_u = 0;
req_u->ron_u = ron_u; req_u->ron_u = ron_u;
if ( ron_u->tou_u ) { if ( ron_u->tou_u ) {
@ -1030,7 +1030,7 @@ _raft_getaddrinfo_cb(uv_getaddrinfo_t* raq_u,
struct addrinfo* add_u) struct addrinfo* add_u)
{ {
struct addrinfo* res_u; struct addrinfo* res_u;
uv_connect_t* con_u = malloc(sizeof(*con_u)); uv_connect_t* con_u = c3_malloc(sizeof(*con_u));
u2_rcon* ron_u = raq_u->data; u2_rcon* ron_u = raq_u->data;
//uL(fprintf(uH, "getaddrinfo_cb %s\n", ron_u->nam_u->nam_c)); //uL(fprintf(uH, "getaddrinfo_cb %s\n", ron_u->nam_u->nam_c));
@ -1077,7 +1077,7 @@ _raft_conn_all(u2_raft* raf_u, void (*con_f)(u2_rcon* ron_u))
while ( nam_u ) { while ( nam_u ) {
if ( 0 == nam_u->ron_u || u2_no == nam_u->ron_u->liv ) { if ( 0 == nam_u->ron_u || u2_no == nam_u->ron_u->liv ) {
struct addrinfo hit_u; struct addrinfo hit_u;
uv_getaddrinfo_t* raq_u = malloc(sizeof(*raq_u)); uv_getaddrinfo_t* raq_u = c3_malloc(sizeof(*raq_u));
ron_u = _raft_conn_new(raf_u); ron_u = _raft_conn_new(raf_u);
@ -1338,7 +1338,7 @@ _raft_foll_init(u2_raft* raf_u)
c3_i wri_i, siz_i; c3_i wri_i, siz_i;
siz_i = strlen(u2_Host.ops_u.nam_c) + strlen(":65536") + 1; siz_i = strlen(u2_Host.ops_u.nam_c) + strlen(":65536") + 1;
raf_u->str_c = malloc(siz_i); raf_u->str_c = c3_malloc(siz_i);
wri_i = snprintf(raf_u->str_c, siz_i, "%s:%d", wri_i = snprintf(raf_u->str_c, siz_i, "%s:%d",
u2_Host.ops_u.nam_c, u2_Host.ops_u.rop_s); u2_Host.ops_u.nam_c, u2_Host.ops_u.rop_s);
c3_assert(wri_i < siz_i); c3_assert(wri_i < siz_i);
@ -1357,7 +1357,7 @@ _raft_foll_init(u2_raft* raf_u)
} }
if ( (ret_i = u2_sist_has("vote")) >= 0 ) { if ( (ret_i = u2_sist_has("vote")) >= 0 ) {
c3_assert(ret_i > 0); c3_assert(ret_i > 0);
vog_c = malloc(ret_i); vog_c = c3_malloc(ret_i);
u2_sist_get("vote", (c3_y*)vog_c); u2_sist_get("vote", (c3_y*)vog_c);
uL(fprintf(uH, "raft: vote from sist: %s\n", vog_c)); uL(fprintf(uH, "raft: vote from sist: %s\n", vog_c));
} }
@ -1742,7 +1742,7 @@ u2_raft_work(u2_reck* rec_u)
u2z(ova); ova = nex; u2z(ova); ova = nex;
if ( u2_nul != ovo ) { if ( u2_nul != ovo ) {
egg_u = malloc(sizeof(*egg_u)); egg_u = c3_malloc(sizeof(*egg_u));
egg_u->nex_u = 0; egg_u->nex_u = 0;
egg_u->cit = u2_no; egg_u->cit = u2_no;
egg_u->did = u2_no; egg_u->did = u2_no;
@ -1753,7 +1753,7 @@ u2_raft_work(u2_reck* rec_u)
ron = u2_dc("en:crya", u2k(rec_u->key), ron); ron = u2_dc("en:crya", u2k(rec_u->key), ron);
len_w = u2_cr_met(5, ron); len_w = u2_cr_met(5, ron);
bob_w = malloc(len_w * 4L); bob_w = c3_malloc(len_w * 4L);
u2_cr_words(0, len_w, bob_w, ron); u2_cr_words(0, len_w, bob_w, ron);
u2z(ron); u2z(ron);

View File

@ -326,7 +326,7 @@ _sist_cask(u2_reck* rec_u, c3_c* dir_c, u2_bean nun)
} }
} }
else { else {
c3_c* say_c = malloc(strlen(paw_c) + 2); c3_c* say_c = c3_malloc(strlen(paw_c) + 2);
u2_noun say; u2_noun say;
say_c[0] = '~'; say_c[0] = '~';
@ -659,7 +659,7 @@ _sist_rest_nuu(u2_ulog* lug_u, u2_uled led_u, c3_c* old_c)
u2_lo_bail(u2A); u2_lo_bail(u2A);
} }
img_w = malloc(4 * lar_u.len_w); img_w = c3_malloc(4 * lar_u.len_w);
end_d = (tar_d - (c3_d)lar_u.len_w); end_d = (tar_d - (c3_d)lar_u.len_w);
if ( -1 == lseek64(fid_i, 4ULL * end_d, SEEK_SET) ) { if ( -1 == lseek64(fid_i, 4ULL * end_d, SEEK_SET) ) {
@ -727,7 +727,7 @@ _sist_rest_nuu(u2_ulog* lug_u, u2_uled led_u, c3_c* old_c)
u2_cr_mug_both(u2_cr_mug(0), u2_cr_mug_both(u2_cr_mug(0),
u2_cr_mug(c3__ov))); u2_cr_mug(c3__ov)));
img_w = malloc(lar_u.len_w << 2); img_w = c3_malloc(lar_u.len_w << 2);
u2_cr_words(0, lar_u.len_w, img_w, ovo); u2_cr_words(0, lar_u.len_w, img_w, ovo);
u2z(ovo); u2z(ovo);
@ -948,7 +948,7 @@ _sist_rest(u2_reck* rec_u)
continue; continue;
} }
img_w = malloc(4 * lar_u.len_w); img_w = c3_malloc(4 * lar_u.len_w);
if ( -1 == lseek64(fid_i, 4ULL * end_d, SEEK_SET) ) { if ( -1 == lseek64(fid_i, 4ULL * end_d, SEEK_SET) ) {
uL(fprintf(uH, "record (%s) is corrupt (h)\n", ful_c)); uL(fprintf(uH, "record (%s) is corrupt (h)\n", ful_c));

View File

@ -36,7 +36,7 @@ static void _term_it_do_writes(u2_utty*);
static uv_buf_t static uv_buf_t
_term_alloc(uv_handle_t* had_u, size_t len_i) _term_alloc(uv_handle_t* had_u, size_t len_i)
{ {
return uv_buf_init(malloc(len_i), len_i); return uv_buf_init(c3_malloc(len_i), len_i);
} }
#endif #endif
@ -45,7 +45,7 @@ _term_alloc(uv_handle_t* had_u, size_t len_i)
void void
u2_term_io_init() u2_term_io_init()
{ {
u2_utty* uty_u = malloc(sizeof(u2_utty)); u2_utty* uty_u = c3_malloc(sizeof(u2_utty));
if ( u2_yes == u2_Host.ops_u.dem ) { if ( u2_yes == u2_Host.ops_u.dem ) {
uty_u->fid_i = 1; uty_u->fid_i = 1;
@ -272,7 +272,7 @@ _term_it_clip(u2_ubuf* buf_u, c3_i siz_i)
static u2_ubuf* static u2_ubuf*
_term_it_buf(c3_w len_w, const c3_y* hun_y) _term_it_buf(c3_w len_w, const c3_y* hun_y)
{ {
u2_ubuf* buf_u = malloc(len_w + sizeof(*buf_u)); u2_ubuf* buf_u = c3_malloc(len_w + sizeof(*buf_u));
buf_u->len_w = len_w; buf_u->len_w = len_w;
memcpy(buf_u->hun_y, hun_y, len_w); memcpy(buf_u->hun_y, hun_y, len_w);
@ -308,7 +308,7 @@ _term_write_cb(uv_write_t* wri_u, c3_i sas_i)
static void static void
_term_it_write_buf(u2_utty* uty_u, uv_buf_t buf_u) _term_it_write_buf(u2_utty* uty_u, uv_buf_t buf_u)
{ {
_u2_write_t* ruq_u = (_u2_write_t*) malloc(sizeof(_u2_write_t)); _u2_write_t* ruq_u = (_u2_write_t*) c3_malloc(sizeof(_u2_write_t));
ruq_u->buf_y = (c3_y*)buf_u.base; ruq_u->buf_y = (c3_y*)buf_u.base;
@ -342,7 +342,7 @@ _term_it_write_old(u2_utty* uty_u,
// XX extra copy here due to old code. Use hbod as base directly. // XX extra copy here due to old code. Use hbod as base directly.
// //
{ {
c3_y* buf_y = malloc(old_u->len_w); c3_y* buf_y = c3_malloc(old_u->len_w);
memcpy(buf_y, old_u->hun_y, old_u->len_w); memcpy(buf_y, old_u->hun_y, old_u->len_w);
buf_u = uv_buf_init((c3_c*)buf_y, old_u->len_w); buf_u = uv_buf_init((c3_c*)buf_y, old_u->len_w);
@ -532,7 +532,7 @@ _term_it_path(u2_bean fyl, u2_noun pax)
// cut // cut
// //
pas_c = malloc(len_w + 1); pas_c = c3_malloc(len_w + 1);
strncpy(pas_c, u2_Host.cpu_c, len_w); strncpy(pas_c, u2_Host.cpu_c, len_w);
pas_c[len_w] = '\0'; pas_c[len_w] = '\0';
{ {
@ -1004,7 +1004,7 @@ _term_ef_blit(u2_utty* uty_u,
case c3__lin: { case c3__lin: {
u2_noun lin = u2t(blt); u2_noun lin = u2t(blt);
c3_w len_w = u2_ckb_lent(u2k(lin)); c3_w len_w = u2_ckb_lent(u2k(lin));
c3_w* lin_w = malloc(4 * len_w); c3_w* lin_w = c3_malloc(4 * len_w);
{ {
c3_w i_w; c3_w i_w;

View File

@ -29,7 +29,7 @@ _unix_down(c3_c* pax_c, c3_c* sub_c)
{ {
c3_w pax_w = strlen(pax_c); c3_w pax_w = strlen(pax_c);
c3_w sub_w = strlen(sub_c); c3_w sub_w = strlen(sub_c);
c3_c* don_c = malloc(pax_w + strlen(sub_c) + 2); c3_c* don_c = c3_malloc(pax_w + strlen(sub_c) + 2);
strncpy(don_c, pax_c, pax_w + 1); strncpy(don_c, pax_c, pax_w + 1);
don_c[pax_w] = '/'; don_c[pax_w] = '/';
@ -231,7 +231,7 @@ _unix_file_form(u2_udir* dir_u,
c3_w pre_w = strlen(pre_c); c3_w pre_w = strlen(pre_c);
c3_w ext_w = strlen(ext_c); c3_w ext_w = strlen(ext_c);
c3_w ket_w = (u2_yes == ket) ? 1 : 0; c3_w ket_w = (u2_yes == ket) ? 1 : 0;
c3_c* pax_c = malloc(pax_w + 1 + pre_w + 1 + ket_w + ext_w + 1); c3_c* pax_c = c3_malloc(pax_w + 1 + pre_w + 1 + ket_w + ext_w + 1);
strncpy(pax_c, dir_u->pax_c, pax_w); strncpy(pax_c, dir_u->pax_c, pax_w);
pax_c[pax_w] = '/'; pax_c[pax_w] = '/';
@ -276,7 +276,7 @@ _unix_dir_forge(u2_udir* dir_u, u2_udir* par_u, u2_noun tet)
c3_c* tet_c = u2_cr_string(tet); c3_c* tet_c = u2_cr_string(tet);
c3_w pax_w = strlen(par_u->pax_c); c3_w pax_w = strlen(par_u->pax_c);
c3_w tet_w = strlen(tet_c); c3_w tet_w = strlen(tet_c);
c3_c* pax_c = malloc(pax_w + 1 + tet_w + 1); c3_c* pax_c = c3_malloc(pax_w + 1 + tet_w + 1);
strncpy(pax_c, par_u->pax_c, pax_w + 1); strncpy(pax_c, par_u->pax_c, pax_w + 1);
pax_c[pax_w] = '/'; pax_c[pax_w] = '/';
@ -504,7 +504,7 @@ _unix_dir_update(u2_udir* dir_u, DIR* rid_u)
} }
} }
if ( !fil_u ) { if ( !fil_u ) {
fil_u = malloc(sizeof(u2_ufil)); fil_u = c3_malloc(sizeof(u2_ufil));
// uL(fprintf(uH, "found file %s\n", pax_c)); // uL(fprintf(uH, "found file %s\n", pax_c));
_unix_file_watch(fil_u, dir_u, pax_c, mod_mp); _unix_file_watch(fil_u, dir_u, pax_c, mod_mp);
@ -524,7 +524,7 @@ _unix_dir_update(u2_udir* dir_u, DIR* rid_u)
} }
if ( !dis_u ) { if ( !dis_u ) {
DIR* red_u = _unix_opendir(pax_c); DIR* red_u = _unix_opendir(pax_c);
dis_u = malloc(sizeof(u2_udir)); dis_u = c3_malloc(sizeof(u2_udir));
// uL(fprintf(uH, "found directory %s\n", pax_c)); // uL(fprintf(uH, "found directory %s\n", pax_c));
_unix_dir_watch(dis_u, dir_u, pax_c); _unix_dir_watch(dis_u, dir_u, pax_c);
@ -562,7 +562,7 @@ _unix_load(c3_c* pax_c)
return 0; return 0;
} }
fln_w = buf_u.st_size; fln_w = buf_u.st_size;
pad_y = malloc(buf_u.st_size); pad_y = c3_malloc(buf_u.st_size);
red_w = read(fid_i, pad_y, fln_w); red_w = read(fid_i, pad_y, fln_w);
close(fid_i); close(fid_i);
@ -595,7 +595,7 @@ _unix_save(c3_c* pax_c, u2_atom oat)
} }
fln_w = u2_met(3, oat); fln_w = u2_met(3, oat);
oat_y = malloc(fln_w); oat_y = c3_malloc(fln_w);
u2_cr_bytes(0, fln_w, oat_y, oat); u2_cr_bytes(0, fln_w, oat_y, oat);
u2z(oat); u2z(oat);
@ -846,7 +846,7 @@ _unix_hot_gain(u2_noun who, u2_bean mek)
u2_unix_acquire(pax_c); u2_unix_acquire(pax_c);
{ {
u2_uhot* hot_u = malloc(sizeof(u2_uhot)); u2_uhot* hot_u = c3_malloc(sizeof(u2_uhot));
_unix_dir_watch(&hot_u->dir_u, 0, pax_c); _unix_dir_watch(&hot_u->dir_u, 0, pax_c);
@ -987,7 +987,7 @@ _unix_desk_sync_tofu(u2_udir* dir_u,
mpz_t mod_mp; mpz_t mod_mp;
u2_cr_mp(mod_mp, u2A->now); u2_cr_mp(mod_mp, u2A->now);
*fil_u = malloc(sizeof(u2_ufil)); *fil_u = c3_malloc(sizeof(u2_ufil));
_unix_file_watch(*fil_u, dir_u, pax_c, mod_mp); _unix_file_watch(*fil_u, dir_u, pax_c, mod_mp);
mpz_clear(mod_mp); mpz_clear(mod_mp);
@ -1019,7 +1019,7 @@ _unix_desk_sync_tako(u2_udir* dir_u, u2_noun pax, u2_noun mis)
u2_udir** dis_u = _unix_pdir(dir_u, u2k(i_pax)); u2_udir** dis_u = _unix_pdir(dir_u, u2k(i_pax));
if ( !*dis_u ) { if ( !*dis_u ) {
*dis_u = malloc(sizeof(u2_udir)); *dis_u = c3_malloc(sizeof(u2_udir));
_unix_dir_forge(*dis_u, dir_u, u2k(i_pax)); _unix_dir_forge(*dis_u, dir_u, u2k(i_pax));
} }
@ -1061,7 +1061,7 @@ _unix_desk_sync_ergo(u2_noun hox,
#endif #endif
if ( !*dir_u ) { if ( !*dir_u ) {
*dir_u = malloc(sizeof(u2_udir)); *dir_u = c3_malloc(sizeof(u2_udir));
xun = u2nt(0, u2_nul, u2_nul); xun = u2nt(0, u2_nul, u2_nul);
_unix_dir_forge(*dir_u, &(hot_u->dir_u), u2k(syd)); _unix_dir_forge(*dir_u, &(hot_u->dir_u), u2k(syd));
@ -1279,7 +1279,7 @@ u2_unix_io_init(void)
{ {
u2_usig* sig_u; u2_usig* sig_u;
sig_u = malloc(sizeof(u2_usig)); sig_u = c3_malloc(sizeof(u2_usig));
uv_signal_init(u2L, &sig_u->sil_u); uv_signal_init(u2L, &sig_u->sil_u);
sig_u->num_i = SIGTERM; sig_u->num_i = SIGTERM;
@ -1289,7 +1289,7 @@ u2_unix_io_init(void)
{ {
u2_usig* sig_u; u2_usig* sig_u;
sig_u = malloc(sizeof(u2_usig)); sig_u = c3_malloc(sizeof(u2_usig));
uv_signal_init(u2L, &sig_u->sil_u); uv_signal_init(u2L, &sig_u->sil_u);
sig_u->num_i = SIGINT; sig_u->num_i = SIGINT;
@ -1299,7 +1299,7 @@ u2_unix_io_init(void)
{ {
u2_usig* sig_u; u2_usig* sig_u;
sig_u = malloc(sizeof(u2_usig)); sig_u = c3_malloc(sizeof(u2_usig));
uv_signal_init(u2L, &sig_u->sil_u); uv_signal_init(u2L, &sig_u->sil_u);
sig_u->num_i = SIGWINCH; sig_u->num_i = SIGWINCH;

View File

@ -59,7 +59,7 @@ u2_walk_safe(c3_c* pas_c)
return 0; return 0;
} }
fln_w = buf_b.st_size; fln_w = buf_b.st_size;
pad_y = malloc(buf_b.st_size); pad_y = c3_malloc(buf_b.st_size);
red_w = read(fid_i, pad_y, fln_w); red_w = read(fid_i, pad_y, fln_w);
close(fid_i); close(fid_i);
@ -91,7 +91,7 @@ u2_walk_load(c3_c* pas_c)
return u2_cm_bail(c3__fail); return u2_cm_bail(c3__fail);
} }
fln_w = buf_b.st_size; fln_w = buf_b.st_size;
pad_y = malloc(buf_b.st_size); pad_y = c3_malloc(buf_b.st_size);
red_w = read(fid_i, pad_y, fln_w); red_w = read(fid_i, pad_y, fln_w);
close(fid_i); close(fid_i);
@ -123,7 +123,7 @@ u2_walk_save(c3_c* pas_c, u2_noun tim, u2_atom pad)
} }
fln_w = u2_met(3, pad); fln_w = u2_met(3, pad);
pad_y = malloc(fln_w); pad_y = c3_malloc(fln_w);
u2_cr_bytes(0, fln_w, pad_y, pad); u2_cr_bytes(0, fln_w, pad_y, pad);
u2z(pad); u2z(pad);
@ -178,7 +178,7 @@ _walk_in(u2_reck* rec_u, const c3_c* dir_c, c3_w len_w)
else { else {
c3_c* fil_c = out_n->d_name; c3_c* fil_c = out_n->d_name;
c3_w lef_w = len_w + 1 + strlen(fil_c); c3_w lef_w = len_w + 1 + strlen(fil_c);
c3_c* pat_c = malloc(lef_w + 1); c3_c* pat_c = c3_malloc(lef_w + 1);
struct stat buf_b; struct stat buf_b;
strncpy(pat_c, dir_c, lef_w); strncpy(pat_c, dir_c, lef_w);
@ -277,7 +277,7 @@ u2_path(u2_bean fyl, u2_noun pax)
// cut // cut
// //
pas_c = malloc(len_w + 1); pas_c = c3_malloc(len_w + 1);
strncpy(pas_c, u2_Local, len_w); strncpy(pas_c, u2_Local, len_w);
pas_c[len_w] = '\0'; pas_c[len_w] = '\0';
{ {