diff --git a/pkg/urbit/daemon/main.c b/pkg/urbit/daemon/main.c index c2a470fae..1e1679ef3 100644 --- a/pkg/urbit/daemon/main.c +++ b/pkg/urbit/daemon/main.c @@ -50,7 +50,7 @@ _main_readw(const c3_c* str_c, c3_w max_w, c3_w* out_w) c3_c* _main_presig(c3_c* txt_c) { - c3_c* new_c = malloc(2 + strlen(txt_c)); + c3_c* new_c = c3_malloc(2 + strlen(txt_c)); if ( '~' == *txt_c ) { strcpy(new_c, txt_c); @@ -663,15 +663,15 @@ main(c3_i argc, // allocates more memory as needed if the path is too large // while ( abs_c != getcwd(abs_c, mprint_i) ) { - free(abs_c); + c3_free(abs_c); mprint_i *= 2; abs_c = c3_malloc(mprint_i); } printf("boot: home is %s/%s\n", abs_c, u3_Host.dir_c); - free(abs_c); + c3_free(abs_c); } else { printf("boot: home is %s\n", abs_c); - free(abs_c); + c3_free(abs_c); } // printf("vere: hostname is %s\n", u3_Host.ops_u.nam_c); diff --git a/pkg/urbit/noun/allocate.c b/pkg/urbit/noun/allocate.c index f15ecc5d5..b27a67cb7 100644 --- a/pkg/urbit/noun/allocate.c +++ b/pkg/urbit/noun/allocate.c @@ -1815,7 +1815,7 @@ _ca_print_leak(c3_c* cap_c, u3a_box* box_u, c3_w eus_w, c3_w use_w) if ( box_u->cod_w ) { c3_c* cod_c = u3m_pretty(box_u->cod_w); fprintf(stderr, "code: %s\r\n", cod_c); - free(cod_c); + c3_free(cod_c); } u3a_print_memory(stderr, " size", box_u->siz_w); @@ -1823,7 +1823,7 @@ _ca_print_leak(c3_c* cap_c, u3a_box* box_u, c3_w eus_w, c3_w use_w) { c3_c* dat_c = _ca_print_box(box_u); fprintf(stderr, " data: %s\r\n", dat_c); - free(dat_c); + c3_free(dat_c); } } @@ -1843,7 +1843,7 @@ _ca_print_leak(c3_c* cap_c, u3a_box* box_u, c3_ws use_ws) { c3_c* dat_c = _ca_print_box(box_u); fprintf(stderr, " data: %s\r\n", dat_c); - free(dat_c); + c3_free(dat_c); } } diff --git a/pkg/urbit/noun/events.c b/pkg/urbit/noun/events.c index a0b5b8ed0..86162741d 100644 --- a/pkg/urbit/noun/events.c +++ b/pkg/urbit/noun/events.c @@ -249,12 +249,12 @@ _ce_patch_read_control(u3_ce_patch* pat_u) len_w = (c3_w) buf_u.st_size; } - pat_u->con_u = malloc(len_w); + pat_u->con_u = c3_malloc(len_w); if ( (len_w != read(pat_u->ctl_i, pat_u->con_u, len_w)) || (len_w != sizeof(u3e_control) + (pat_u->con_u->pgs_w * sizeof(u3e_line))) ) { - free(pat_u->con_u); + c3_free(pat_u->con_u); pat_u->con_u = 0; return c3n; } @@ -347,10 +347,10 @@ _ce_patch_verify(u3_ce_patch* pat_u) static void _ce_patch_free(u3_ce_patch* pat_u) { - free(pat_u->con_u); + c3_free(pat_u->con_u); close(pat_u->ctl_i); close(pat_u->mem_i); - free(pat_u); + c3_free(pat_u); } /* _ce_patch_open(): open patch, if any. @@ -380,7 +380,7 @@ _ce_patch_open(void) _ce_patch_delete(); return 0; } - pat_u = malloc(sizeof(u3_ce_patch)); + pat_u = c3_malloc(sizeof(u3_ce_patch)); pat_u->ctl_i = ctl_i; pat_u->mem_i = mem_i; pat_u->con_u = 0; @@ -388,7 +388,7 @@ _ce_patch_open(void) if ( c3n == _ce_patch_read_control(pat_u) ) { close(pat_u->ctl_i); close(pat_u->mem_i); - free(pat_u); + c3_free(pat_u); _ce_patch_delete(); return 0; @@ -566,11 +566,11 @@ _ce_patch_compose(void) return 0; } else { - u3_ce_patch* pat_u = malloc(sizeof(u3_ce_patch)); + u3_ce_patch* pat_u = c3_malloc(sizeof(u3_ce_patch)); c3_w i_w, pgc_w; _ce_patch_create(pat_u); - pat_u->con_u = malloc(sizeof(u3e_control) + (pgs_w * sizeof(u3e_line))); + pat_u->con_u = c3_malloc(sizeof(u3e_control) + (pgs_w * sizeof(u3e_line))); pgc_w = 0; for ( i_w = 0; i_w < nor_w; i_w++ ) { diff --git a/pkg/urbit/noun/imprison.c b/pkg/urbit/noun/imprison.c index 2b376041c..df5ce3e42 100644 --- a/pkg/urbit/noun/imprison.c +++ b/pkg/urbit/noun/imprison.c @@ -65,7 +65,7 @@ u3i_chubs(c3_w a_w, b_w[(2 * i_w) + 1] = b_d[i_w] >> 32ULL; } p = u3i_words((a_w * 2), b_w); - free(b_w); + c3_free(b_w); return p; } diff --git a/pkg/urbit/noun/jets.c b/pkg/urbit/noun/jets.c index 0a41892dd..2ae4aea40 100644 --- a/pkg/urbit/noun/jets.c +++ b/pkg/urbit/noun/jets.c @@ -414,7 +414,7 @@ _cj_chum(u3_noun chu) memset(buf, 0, 33); snprintf(buf, 32, "%s%d", h_chu_c, t_chu); - free(h_chu_c); + c3_free(h_chu_c); return strdup(buf); } } @@ -440,7 +440,7 @@ _cj_je_fsck(u3_noun clu) q_clu = u3t(u3t(q_clu)); } if ( !_(u3du(q_clu)) ) { - u3z(clu); free(nam_c); return u3_none; + u3z(clu); c3_free(nam_c); return u3_none; } if ( (1 == u3h(q_clu)) && (0 == u3t(q_clu)) ) { @@ -448,7 +448,7 @@ _cj_je_fsck(u3_noun clu) } else { if ( (0 != u3h(q_clu)) || !_(u3a_is_cat(axe_l = u3t(q_clu))) ) { - u3z(clu); free(nam_c); return u3_none; + u3z(clu); c3_free(nam_c); return u3_none; } } @@ -462,7 +462,7 @@ _cj_je_fsck(u3_noun clu) (c3n == u3r_cell(ir_clu, &pir_clu, &qir_clu)) || (c3n == u3ud(pir_clu)) ) { - u3z(huk); u3z(clu); free(nam_c); return u3_none; + u3z(huk); u3z(clu); c3_free(nam_c); return u3_none; } huk = u3kdb_put(huk, u3k(pir_clu), u3k(qir_clu)); r_clu = tr_clu; @@ -472,7 +472,7 @@ _cj_je_fsck(u3_noun clu) { u3_noun pro = u3nt(u3i_string(nam_c), axe_l, huk); - free(nam_c); + c3_free(nam_c); return pro; } } @@ -825,7 +825,7 @@ u3j_boot(c3_o nuu_o) u3D.len_l =_cj_count(0, u3D.dev_u); u3D.all_l = (2 * u3D.len_l) + 1024; // horrid heuristic - u3D.ray_u = (u3j_core*) malloc(u3D.all_l * sizeof(u3j_core)); + u3D.ray_u = c3_malloc(u3D.all_l * sizeof(u3j_core)); memset(u3D.ray_u, 0, (u3D.all_l * sizeof(u3j_core))); if ( c3n == nuu_o ) { diff --git a/pkg/urbit/noun/manage.c b/pkg/urbit/noun/manage.c index e40795c95..fbc7bb076 100644 --- a/pkg/urbit/noun/manage.c +++ b/pkg/urbit/noun/manage.c @@ -417,12 +417,12 @@ u3m_file(c3_c* pas_c) close(fid_i); if ( fln_w != red_w ) { - free(pad_y); + c3_free(pad_y); return u3m_bail(c3__fail); } else { u3_noun pad = u3i_bytes(fln_w, (c3_y *)pad_y); - free(pad_y); + c3_free(pad_y); return pad; } @@ -1354,7 +1354,7 @@ _cm_in_pretty(u3_noun som, c3_o sel_o, c3_c* str_c) } else { c3_w len_w = u3r_met(3, som); - c3_c *buf_c = malloc(2 + (2 * len_w) + 1); + c3_c *buf_c = c3_malloc(2 + (2 * len_w) + 1); c3_w i_w = 0; c3_w a_w = 0; @@ -1376,7 +1376,7 @@ _cm_in_pretty(u3_noun som, c3_o sel_o, c3_c* str_c) if ( str_c ) { strcpy(str_c, buf_c); str_c += len_w; } - free(buf_c); + c3_free(buf_c); return len_w; } } @@ -1389,7 +1389,7 @@ c3_c* u3m_pretty(u3_noun som) { c3_w len_w = _cm_in_pretty(som, c3y, 0); - c3_c* pre_c = malloc(len_w + 1); + c3_c* pre_c = c3_malloc(len_w + 1); _cm_in_pretty(som, c3y, pre_c); pre_c[len_w] = 0; @@ -1439,7 +1439,7 @@ c3_c* u3m_pretty_path(u3_noun som) { c3_w len_w = _cm_in_pretty_path(som, NULL); - c3_c* pre_c = malloc(len_w + 1); + c3_c* pre_c = c3_malloc(len_w + 1); _cm_in_pretty_path(som, pre_c); pre_c[len_w] = 0; @@ -1454,7 +1454,7 @@ u3m_p(const c3_c* cap_c, u3_noun som) c3_c* pre_c = u3m_pretty(som); u3l_log("%s: %s\r\n", cap_c, pre_c); - free(pre_c); + c3_free(pre_c); } /* u3m_tape(): dump a tape to stdout. diff --git a/pkg/urbit/noun/trace.c b/pkg/urbit/noun/trace.c index d4fc25bd8..1350adc0e 100644 --- a/pkg/urbit/noun/trace.c +++ b/pkg/urbit/noun/trace.c @@ -397,7 +397,7 @@ u3t_nock_trace_pop() start_time, duration); - free(name); + c3_free(name); u3_Host.tra_u.con_w++; } diff --git a/pkg/urbit/noun/vortex.c b/pkg/urbit/noun/vortex.c index e1779854a..8bb1bae0e 100644 --- a/pkg/urbit/noun/vortex.c +++ b/pkg/urbit/noun/vortex.c @@ -145,7 +145,7 @@ _cv_nock_poke(u3_noun ovo) c3_c* tox_c = u3r_string(tox); u3l_log("poke: %%%s (%x) on %s\r\n", ovi_c, u3r_mug(ovo), tox_c); - free(tox_c); free(ovi_c); u3z(tox); + c3_free(tox_c); c3_free(ovi_c); u3z(tox); } #endif @@ -162,7 +162,7 @@ _cv_nock_poke(u3_noun ovo) } else { u3l_log(" happy: %s: %d\r\n", ovi_c, u3kb_lent(u3k(u3h(pro)))); } - free(ovi_c); + c3_free(ovi_c); } #endif diff --git a/pkg/urbit/vere/ames.c b/pkg/urbit/vere/ames.c index b15a6d99e..1c28df28b 100644 --- a/pkg/urbit/vere/ames.c +++ b/pkg/urbit/vere/ames.c @@ -31,23 +31,14 @@ _ames_alloc(uv_handle_t* had_u, *buf = uv_buf_init(ptr_v, 2048); } -/* _ames_free(): contrasting free. -*/ -static void -_ames_free(void* ptr_v) -{ -// u3l_log("free %p\n", ptr_v); - free(ptr_v); -} - /* _ames_pact_free(): free packet struct. */ static void _ames_pact_free(u3_pact* pac_u) { - free(pac_u->hun_y); - free(pac_u->dns_c); - free(pac_u); + c3_free(pac_u->hun_y); + c3_free(pac_u->dns_c); + c3_free(pac_u); } /* _ames_send_cb(): send callback. @@ -178,7 +169,7 @@ _ames_czar_cb(uv_getaddrinfo_t* adr_u, u3l_log("ames: czar %s: ip %s\n", pac_u->dns_c, nam_c); - free(nam_c); u3z(nam); + c3_free(nam_c); u3z(nam); } #endif @@ -189,7 +180,7 @@ _ames_czar_cb(uv_getaddrinfo_t* adr_u, rai_u = rai_u->ai_next; } - free(adr_u); + c3_free(adr_u); uv_freeaddrinfo(aif_u); } @@ -245,7 +236,7 @@ _ames_czar(u3_pact* pac_u, c3_c* bos_c) c3_c* nam_c = u3r_string(nam); u3l_log("ames: no galaxy domain for %s, no-op\r\n", nam_c); - free(nam_c); + c3_free(nam_c); u3z(nam); return; } @@ -269,7 +260,7 @@ _ames_czar(u3_pact* pac_u, c3_c* bos_c) snprintf(pac_u->dns_c, 256, "%s.%s", nam_c + 1, bos_c); // u3l_log("czar %s, dns %s\n", nam_c, pac_u->dns_c); - free(nam_c); + c3_free(nam_c); u3z(nam); { @@ -372,12 +363,12 @@ _ames_recv_cb(uv_udp_t* wax_u, // u3l_log("ames: rx %p\r\n", buf_u.base); if ( 0 == nrd_i ) { - _ames_free(buf_u->base); + c3_free(buf_u->base); } // check protocol version in header matches 0 // else if ( 0 != (0x7 & *((c3_w*)buf_u->base)) ) { - _ames_free(buf_u->base); + c3_free(buf_u->base); } else { { @@ -398,7 +389,7 @@ _ames_recv_cb(uv_udp_t* wax_u, u3_pier_plan(u3nt(u3_blip, c3__ames, u3_nul), mov); #endif } - _ames_free(buf_u->base); + c3_free(buf_u->base); } } diff --git a/pkg/urbit/vere/cttp.c b/pkg/urbit/vere/cttp.c index 9554a9092..911a4b611 100644 --- a/pkg/urbit/vere/cttp.c +++ b/pkg/urbit/vere/cttp.c @@ -32,7 +32,7 @@ _cttp_bods_free(u3_hbod* bod_u) while ( bod_u ) { u3_hbod* nex_u = bod_u->nex_u; - free(bod_u); + c3_free(bod_u); bod_u = nex_u; } } @@ -102,7 +102,7 @@ _cttp_bods_to_octs(u3_hbod* bod_u) } } cos = u3i_bytes(len_w, buf_y); - free(buf_y); + c3_free(buf_y); return u3nc(len_w, cos); } @@ -177,9 +177,9 @@ _cttp_heds_free(u3_hhed* hed_u) while ( hed_u ) { u3_hhed* nex_u = hed_u->nex_u; - free(hed_u->nam_c); - free(hed_u->val_c); - free(hed_u); + c3_free(hed_u->nam_c); + c3_free(hed_u->val_c); + c3_free(hed_u); hed_u = nex_u; } } @@ -258,7 +258,7 @@ static void _cttp_cres_free(u3_cres* res_u) { _cttp_bods_free(res_u->bod_u); - free(res_u); + c3_free(res_u); } /* _cttp_cres_new(): create a response @@ -521,12 +521,12 @@ _cttp_creq_free(u3_creq* ceq_u) _cttp_cres_free(ceq_u->res_u); } - free(ceq_u->hot_c); - free(ceq_u->por_c); - free(ceq_u->met_c); - free(ceq_u->url_c); - free(ceq_u->vec_u); - free(ceq_u); + c3_free(ceq_u->hot_c); + c3_free(ceq_u->por_c); + c3_free(ceq_u->met_c); + c3_free(ceq_u->url_c); + c3_free(ceq_u->vec_u); + c3_free(ceq_u); } /* _cttp_creq_new(): create a u3_creq from an +http-request @@ -663,7 +663,7 @@ _cttp_creq_fire(u3_creq* ceq_u) } _cttp_creq_fire_body(ceq_u, _cttp_bod_new(len_w, hos_c)); - free(hos_c); + c3_free(hos_c); } _cttp_creq_fire_heds(ceq_u, ceq_u->hed_u); @@ -844,7 +844,7 @@ _cttp_creq_connect(u3_creq* ceq_u) c3_c* hot_c = c3_malloc(len_w); strncpy(hot_c, ceq_u->hot_c, len_w); - free(ceq_u->cli_u->ssl.server_name); + c3_free(ceq_u->cli_u->ssl.server_name); ceq_u->cli_u->ssl.server_name = hot_c; } @@ -875,7 +875,7 @@ _cttp_creq_resolve_cb(uv_getaddrinfo_t* adr_u, _cttp_creq_connect(ceq_u); } - free(adr_u); + c3_free(adr_u); uv_freeaddrinfo(aif_u); } @@ -1023,6 +1023,6 @@ void u3_cttp_io_exit(void) { SSL_CTX_free(u3_Host.ctp_u.tls_u); - free(u3_Host.ctp_u.ctx_u->io_timeout); - free(u3_Host.ctp_u.ctx_u); + c3_free(u3_Host.ctp_u.ctx_u->io_timeout); + c3_free(u3_Host.ctp_u.ctx_u); } diff --git a/pkg/urbit/vere/daemon.c b/pkg/urbit/vere/daemon.c index 75792df98..47add4bde 100644 --- a/pkg/urbit/vere/daemon.c +++ b/pkg/urbit/vere/daemon.c @@ -600,7 +600,7 @@ _boothack_key(u3_noun kef) if ( u3_nul == des ) { c3_c* kef_c = u3r_string(kef); u3l_log("dawn: invalid private keys: %s\r\n", kef_c); - free(kef_c); + c3_free(kef_c); exit(1); } @@ -631,7 +631,7 @@ _boothack_key(u3_noun kef) u3_Host.ops_u.who_c, how_c); u3z(how); - free(how_c); + c3_free(how_c); exit(1); } @@ -973,7 +973,7 @@ u3_daemon_grab(void* vod_p) fil_u = fopen(man_c, "w"); fprintf(fil_u, "%s\r\n", wen_c); - free(wen_c); + c3_free(wen_c); u3z(wen); } #else diff --git a/pkg/urbit/vere/dawn.c b/pkg/urbit/vere/dawn.c index f6b548214..e92a6705d 100644 --- a/pkg/urbit/vere/dawn.c +++ b/pkg/urbit/vere/dawn.c @@ -205,7 +205,7 @@ _dawn_fail(u3_noun who, u3_noun rac, u3_noun sas) u3m_p("pre-boot error", u3t(sas)); u3z(how); - free(how_c); + c3_free(how_c); exit(1); } @@ -440,7 +440,7 @@ u3_dawn_vent(u3_noun seed) c3_c* who_c = u3r_string(who); u3l_log("boot: retrieving keys for sponsor %s\r\n", who_c); u3z(who); - free(who_c); + c3_free(who_c); } // retrieve +point:azimuth of pos (sponsor of ship) @@ -519,12 +519,12 @@ _dawn_come(u3_noun stars) fclose(fil_u); } - free(key_c); + c3_free(key_c); u3z(key); } #endif - free(who_c); + c3_free(who_c); u3z(who); } diff --git a/pkg/urbit/vere/http.c b/pkg/urbit/vere/http.c index e888fa1f0..1de98afb6 100644 --- a/pkg/urbit/vere/http.c +++ b/pkg/urbit/vere/http.c @@ -41,6 +41,14 @@ static const c3_i TCP_BACKLOG = 16; // #define PROXY_DOMAIN "arvo.network" +/* _http_close_cb(): uv_close_cb that just free's handle +*/ +static void +_http_close_cb(uv_handle_t* han_u) +{ + c3_free(han_u); +} + /* _http_vec_to_meth(): convert h2o_iovec_t to meth */ static u3_weak @@ -89,7 +97,7 @@ _cttp_bods_free(u3_hbod* bod_u) while ( bod_u ) { u3_hbod* nex_u = bod_u->nex_u; - free(bod_u); + c3_free(bod_u); bod_u = nex_u; } } @@ -178,9 +186,9 @@ _http_heds_free(u3_hhed* hed_u) while ( hed_u ) { u3_hhed* nex_u = hed_u->nex_u; - free(hed_u->nam_c); - free(hed_u->val_c); - free(hed_u); + c3_free(hed_u->nam_c); + c3_free(hed_u->val_c); + c3_free(hed_u); hed_u = nex_u; } } @@ -332,7 +340,7 @@ _http_req_done(void* ptr_v) } if ( 0 != req_u->tim_u ) { - uv_close((uv_handle_t*)req_u->tim_u, (uv_close_cb)free); + uv_close((uv_handle_t*)req_u->tim_u, _http_close_cb); req_u->tim_u = 0; } @@ -791,7 +799,7 @@ _http_conn_free(uv_handle_t* han_t) _http_serv_free(htp_u); } - free(hon_u); + c3_free(hon_u); } /* _http_conn_new(): create and accept http connection. @@ -896,8 +904,8 @@ _http_h2o_context_dispose(h2o_context_t* ctx) h2o_context_dispose_pathconf_context(ctx, &hostconf->fallback_path); } - free(ctx->_pathconfs_inited.entries); - free(ctx->_module_configs); + c3_free(ctx->_pathconfs_inited.entries); + c3_free(ctx->_module_configs); h2o_timeout_dispose(ctx->loop, &ctx->zero_timeout); h2o_timeout_dispose(ctx->loop, &ctx->hundred_ms_timeout); @@ -923,7 +931,7 @@ _http_h2o_context_dispose(h2o_context_t* ctx) } } - free(ctx->storage.entries); + c3_free(ctx->storage.entries); h2o_multithread_unregister_receiver(ctx->queue, &ctx->receivers.hostinfo_getaddr); h2o_multithread_destroy_queue(ctx->queue); @@ -953,12 +961,12 @@ _http_serv_really_free(u3_http* htp_u) // XX h2o_cleanup_thread if not restarting? - free(htp_u->h2o_u); + c3_free(htp_u->h2o_u); htp_u->h2o_u = 0; } _http_serv_unlink(htp_u); - free(htp_u); + c3_free(htp_u); } /* http_serv_free_cb(): timer callback for freeing http server. @@ -974,7 +982,7 @@ http_serv_free_cb(uv_timer_t* tim_u) _http_serv_really_free(htp_u); - uv_close((uv_handle_t*)tim_u, (uv_close_cb)free); + uv_close((uv_handle_t*)tim_u, _http_close_cb); } /* _http_serv_free(): begin to free http server. @@ -1184,8 +1192,8 @@ _http_serv_init_h2o(SSL_CTX* tls_u, c3_o log, c3_o red) h2o_access_log_register(&h2o_u->hos_u->fallback_path, fil_u); - free(paf_c); - free(now_c); + c3_free(paf_c); + c3_free(now_c); u3z(now); #endif } @@ -1418,7 +1426,7 @@ _http_write_ports_file(c3_c *pax_c) snprintf(paf_c, len_w, "%s/%s", pax_c, nam_c); c3_i por_i = open(paf_c, O_WRONLY | O_CREAT | O_TRUNC, 0666); - free(paf_c); + c3_free(paf_c); u3_http* htp_u = u3_Host.htp_u; @@ -1449,7 +1457,7 @@ _http_release_ports_file(c3_c *pax_c) snprintf(paf_c, len_w, "%s/%s", pax_c, nam_c); unlink(paf_c); - free(paf_c); + c3_free(paf_c); } /* u3_http_ef_bake(): notify %eyre that we're live @@ -1668,14 +1676,14 @@ _http_form_free(void) } if ( 0 != for_u->key_u.base ) { - free(for_u->key_u.base); + c3_free(for_u->key_u.base); } if ( 0 != for_u->cer_u.base ) { - free(for_u->cer_u.base); + c3_free(for_u->cer_u.base); } - free(for_u); + c3_free(for_u); u3_Host.fig_u.for_u = 0; } @@ -1834,9 +1842,9 @@ static void _proxy_warc_free(u3_warc* cli_u) { _proxy_warc_unlink(cli_u); - free(cli_u->non_u.base); - free(cli_u->hot_c); - free(cli_u); + c3_free(cli_u->non_u.base); + c3_free(cli_u->hot_c); + c3_free(cli_u); } /* _proxy_warc_new(): allocate ship-specific proxy client @@ -1948,7 +1956,7 @@ _proxy_conn_free(uv_handle_t* han_u) u3_pcon* con_u = han_u->data; if ( 0 != con_u->buf_u.base ) { - free(con_u->buf_u.base); + c3_free(con_u->buf_u.base); } if ( u3_ptyp_ward == con_u->typ_e ) { @@ -1957,7 +1965,7 @@ _proxy_conn_free(uv_handle_t* han_u) _proxy_conn_unlink(con_u); - free(con_u); + c3_free(con_u); } /* _proxy_conn_close(): close both sides of proxy connection @@ -1972,7 +1980,7 @@ _proxy_conn_close(u3_pcon* con_u) } if ( 0 != con_u->upt_u ) { - uv_close((uv_handle_t*)con_u->upt_u, (uv_close_cb)free); + uv_close((uv_handle_t*)con_u->upt_u, _http_close_cb); } uv_close((uv_handle_t*)&con_u->don_u, _proxy_conn_free); @@ -2048,11 +2056,11 @@ _proxy_write_cb(uv_write_t* wri_u, c3_i sas_i) if ( 0 != wri_u->data ) { proxy_write_ctx* ctx_u = wri_u->data; - free(ctx_u->buf_c); - free(ctx_u); + c3_free(ctx_u->buf_c); + c3_free(ctx_u); } - free(wri_u); + c3_free(wri_u); } /* _proxy_write(): write buffer to proxy stream @@ -2157,7 +2165,7 @@ _proxy_loop_connect_cb(uv_connect_t * upc_u, c3_i sas_i) _proxy_fire(con_u); } - free(upc_u); + c3_free(upc_u); } /* _proxy_loop_connect(): connect to loopback. @@ -2211,7 +2219,7 @@ _proxy_loop_connect(u3_pcon* con_u) (const struct sockaddr*)&lop_u, _proxy_loop_connect_cb)) ) { u3l_log("proxy: connect: %s\n", uv_strerror(sas_i)); - free(upc_u); + c3_free(upc_u); _proxy_conn_close(con_u); } } @@ -2257,7 +2265,7 @@ _proxy_wcon_free(uv_handle_t* han_u) u3_wcon* won_u = han_u->data; // Note: not unlinked here, freed concurrent with u3_ward - free(won_u); + c3_free(won_u); } /* _proxy_wcon_close(): close ward upstream candidate. @@ -2333,8 +2341,8 @@ _proxy_ward_free(uv_handle_t* han_u) { u3_ward* rev_u = han_u->data; - free(rev_u->non_u.base); - free(rev_u); + c3_free(rev_u->non_u.base); + c3_free(rev_u); } /* _proxy_ward_close_timer(): close ward timer @@ -2553,7 +2561,7 @@ _proxy_ward_start(u3_pcon* con_u, u3_noun sip) u3_noun who = u3dc("scot", 'p', u3k(sip)); c3_c* who_c = u3r_string(who); u3l_log("\r\nward for %s started on %u\r\n", who_c, rev_u->por_s); - free(who_c); + c3_free(who_c); u3z(who); } #endif @@ -2592,7 +2600,7 @@ _proxy_ward_connect_cb(uv_connect_t * upc_u, c3_i sas_i) cli_u->non_u = uv_buf_init(0, 0); } - free(upc_u); + c3_free(upc_u); } /* _proxy_ward_connect(): connect to remote ward @@ -2620,7 +2628,7 @@ _proxy_ward_connect(u3_warc* cli_u) (const struct sockaddr*)&add_u, _proxy_ward_connect_cb)) ) { u3l_log("proxy: ward connect: %s\n", uv_strerror(sas_i)); - free(upc_u); + c3_free(upc_u); _proxy_conn_close(con_u); } } @@ -2644,7 +2652,7 @@ _proxy_ward_resolve_cb(uv_getaddrinfo_t* adr_u, _proxy_ward_connect(cli_u); } - free(adr_u); + c3_free(adr_u); uv_freeaddrinfo(aif_u); } @@ -2673,7 +2681,7 @@ _proxy_ward_resolve(u3_warc* cli_u) // incremented to skip '~' snprintf(cli_u->hot_c, len_w, "%s.%s", sip_c + 1, PROXY_DOMAIN); - free(sip_c); + c3_free(sip_c); u3z(sip); } @@ -2806,7 +2814,7 @@ _proxy_parse_ship(c3_c* hot_c) sip_c[1 + dif_w] = 0; sip = u3dc("slaw", 'p', u3i_string(sip_c)); - free(sip_c); + c3_free(sip_c); return sip; } @@ -2881,7 +2889,7 @@ _proxy_peek(u3_pcon* con_u) } if ( 0 != hot_c ) { - free(hot_c); + c3_free(hot_c); } } @@ -2913,7 +2921,7 @@ _proxy_peek_read_cb(uv_stream_t* don_u, memcpy(ptr_v + con_u->buf_u.len, buf_u->base, siz_w); con_u->buf_u = uv_buf_init(ptr_v, len_w); - free(buf_u->base); + c3_free(buf_u->base); } _proxy_peek(con_u); @@ -2950,7 +2958,7 @@ _proxy_serv_free(u3_prox* lis_u) // not unlinked here, owned directly by htp_u - free(lis_u); + c3_free(lis_u); } /* _proxy_serv_close(): close proxy listener diff --git a/pkg/urbit/vere/lmdb.c b/pkg/urbit/vere/lmdb.c index 8a5fd9d90..b46cc66ee 100644 --- a/pkg/urbit/vere/lmdb.c +++ b/pkg/urbit/vere/lmdb.c @@ -135,7 +135,7 @@ c3_o _perform_put_on_database_noun(MDB_txn* transaction_u, // copy the jammed noun into a byte buffer we can hand to lmdb c3_w len_w = u3r_met(3, mat); - c3_y* bytes_y = (c3_y*) malloc(len_w); + c3_y* bytes_y = c3_malloc(len_w); u3r_bytes(0, len_w, bytes_y, mat); c3_o ret = _perform_put_on_database_raw( @@ -145,7 +145,7 @@ c3_o _perform_put_on_database_noun(MDB_txn* transaction_u, key, strlen(key), bytes_y, len_w); - free(bytes_y); + c3_free(bytes_y); u3z(mat); return ret; @@ -230,11 +230,11 @@ u3_lmdb_build_write_request(u3_writ* event_u, c3_d count) */ void u3_lmdb_free_write_request(struct u3_lmdb_write_request* request) { for (c3_d i = 0; i < request->event_count; ++i) - free(request->malloced_event_data[i]); + c3_free(request->malloced_event_data[i]); - free(request->malloced_event_data); - free(request->malloced_event_data_size); - free(request); + c3_free(request->malloced_event_data); + c3_free(request->malloced_event_data_size); + c3_free(request); } /* _write_request_data: callback struct for u3_lmdb_write_event() @@ -344,8 +344,8 @@ static void _u3_lmdb_write_event_after_cb(uv_work_t* req, int status) { data->request->event_count); u3_lmdb_free_write_request(data->request); - free(data); - free(req); + c3_free(data); + c3_free(req); } /* u3_lmdb_write_event(): Asynchronously writes events to the database. diff --git a/pkg/urbit/vere/newt.c b/pkg/urbit/vere/newt.c index ed5056d4f..c60083a44 100644 --- a/pkg/urbit/vere/newt.c +++ b/pkg/urbit/vere/newt.c @@ -312,8 +312,8 @@ _newt_write_cb(uv_write_t* wri_u, c3_i sas_i) void* vod_p = req_u->vod_p; u3_mojo* moj_u = req_u->moj_u; - free(req_u->buf_y); - free(req_u); + c3_free(req_u->buf_y); + c3_free(req_u); if ( 0 != sas_i ) { u3l_log("newt: bad write %d\r\n", sas_i); diff --git a/pkg/urbit/vere/pier.c b/pkg/urbit/vere/pier.c index d3c5b8aa3..ee0d1f89e 100644 --- a/pkg/urbit/vere/pier.c +++ b/pkg/urbit/vere/pier.c @@ -803,7 +803,7 @@ _pier_work_stdr(u3_writ* wit_u, u3_noun cord) { c3_c* str = u3r_string(cord); u3C.stderr_log_f(str); - free(str); + c3_free(str); } /* _pier_work_slog(): print directly. @@ -1341,7 +1341,7 @@ _pier_boot_dispose(u3_boot* bot_u) u3z(bot_u->pil); u3z(bot_u->ven); - free(bot_u); + c3_free(bot_u); pir_u->bot_u = 0; } diff --git a/pkg/urbit/vere/reck.c b/pkg/urbit/vere/reck.c index f5abbbe14..cafe0f651 100644 --- a/pkg/urbit/vere/reck.c +++ b/pkg/urbit/vere/reck.c @@ -67,7 +67,7 @@ _reck_orchid(u3_noun fot, u3_noun txt, c3_l* tid_l) { c3_c* str = u3r_string(txt); c3_d ato_d = strtol(str, NULL, 10); - free(str); + c3_free(str); if ( ato_d >= 0x80000000ULL ) { return c3n; diff --git a/pkg/urbit/vere/term.c b/pkg/urbit/vere/term.c index a3f347762..ea820714a 100644 --- a/pkg/urbit/vere/term.c +++ b/pkg/urbit/vere/term.c @@ -88,7 +88,7 @@ _term_close_cb(uv_handle_t* han_t) u3_pier_plan(u3k(pax), u3nc(c3__hook, u3_nul)); u3z(pax); } - free(tty_u); + c3_free(tty_u); } #endif @@ -325,8 +325,8 @@ _term_write_cb(uv_write_t* wri_u, c3_i sas_i) u3l_log("term: write: %s\n", uv_strerror(sas_i)); } - free(wri_u->data); - free(wri_u); + c3_free(wri_u->data); + c3_free(wri_u); } /* _term_it_write_buf(): write buffer uv style. @@ -363,7 +363,7 @@ _term_it_write_old(u3_utty* uty_u, memcpy(buf_y, old_u->hun_y, old_u->len_w); buf_u = uv_buf_init((c3_c*)buf_y, old_u->len_w); - free(old_u); + c3_free(old_u); } _term_it_write_buf(uty_u, buf_u); } @@ -406,7 +406,7 @@ _term_it_show_wide(u3_utty* uty_u, c3_w len_w, c3_w* txt_w) c3_c* txt_c = u3r_string(txt); _term_it_write_str(uty_u, txt_c); - free(txt_c); + c3_free(txt_c); u3z(txt); uty_u->tat_u.mir.cus_w += len_w; @@ -465,7 +465,7 @@ _term_it_show_line(u3_utty* uty_u, c3_w* lin_w, c3_w len_w) if ( lin_w != uty_u->tat_u.mir.lin_w ) { if ( uty_u->tat_u.mir.lin_w ) { - free(uty_u->tat_u.mir.lin_w); + c3_free(uty_u->tat_u.mir.lin_w); } uty_u->tat_u.mir.lin_w = lin_w; } @@ -569,8 +569,8 @@ _term_it_save(u3_noun pax, u3_noun pad) u3_walk_save(pax_c, 0, pad, bas_c, xap); - free(pax_c); - free(bas_c); + c3_free(pax_c); + c3_free(bas_c); } /* _term_io_belt(): send belt. @@ -731,7 +731,7 @@ _term_read_cb(uv_stream_t* tcp_u, { u3_utty* uty_u = (u3_utty*)(void*)tcp_u; _term_suck(uty_u, (const c3_y*)buf_u->base, siz_i); - free(buf_u->base); + c3_free(buf_u->base); } /* _term_spin_write_str(): write null-terminated string @@ -835,7 +835,7 @@ u3_term_start_spinner(c3_c* why_c, c3_o now_o) u3_utty* uty_u = _term_main(); u3_utat* tat_u = &uty_u->tat_u; - free(tat_u-> sun_u.why_c); + c3_free(tat_u-> sun_u.why_c); tat_u->sun_u.why_c = why_c; tat_u->sun_u.eve_d = 0; @@ -1058,7 +1058,7 @@ _term_ef_blit(u3_utty* uty_u, _term_it_show_clear(uty_u); _term_it_write_str(uty_u, txt_c); - free(txt_c); + c3_free(txt_c); _term_it_show_more(uty_u); _term_it_refresh_line(uty_u); diff --git a/pkg/urbit/vere/unix.c b/pkg/urbit/vere/unix.c index c9f87f535..811b22357 100644 --- a/pkg/urbit/vere/unix.c +++ b/pkg/urbit/vere/unix.c @@ -195,7 +195,7 @@ _unix_write_file_hard(c3_c* pax_c, u3_noun mim) } close(fid_i); - free(dat_y); + c3_free(dat_y); return mug_w; } @@ -242,7 +242,7 @@ _unix_write_file_soft(u3_ufil* fil_u, u3_noun mim) u3l_log("wrong # of bytes read in file %s: %d %d\r\n", fil_u->pax_c, len_ws, red_ws); } - free(old_y); + c3_free(old_y); u3z(mim); return; } @@ -251,12 +251,12 @@ _unix_write_file_soft(u3_ufil* fil_u, u3_noun mim) if ( old_w != fil_u->gum_w ) { fil_u->gum_w = u3r_mug(u3t(u3t(mim))); // XXX this might fail with - free(old_y); // trailing zeros + c3_free(old_y); // trailing zeros u3z(mim); return; } - free(old_y); + c3_free(old_y); _unix_write_file_soft_go: fil_u->gum_w = _unix_write_file_hard(fil_u->pax_c, mim); @@ -301,7 +301,7 @@ _unix_get_mount_point(u3_pier *pir_u, u3_noun mon) } else { - free(nam_c); + c3_free(nam_c); } u3z(mon); @@ -351,12 +351,12 @@ _unix_scan_mount_point(u3_pier *pir_u, u3_umon* mon_u) if ( 0 != stat(pax_c, &buf_u) ) { u3l_log("can't stat pier directory %s: %s\r\n", mon_u->dir_u.pax_c, strerror(errno)); - free(pax_c); + c3_free(pax_c); continue; } if ( S_ISDIR(buf_u.st_mode) ) { if ( out_u->d_name[len_w] != '\0' ) { - free(pax_c); + c3_free(pax_c); continue; } else { @@ -371,7 +371,7 @@ _unix_scan_mount_point(u3_pier *pir_u, u3_umon* mon_u) || ('#' == out_u->d_name[0] && '#' == out_u->d_name[strlen(out_u->d_name) - 1]) ) { - free(pax_c); + c3_free(pax_c); continue; } else { @@ -380,7 +380,7 @@ _unix_scan_mount_point(u3_pier *pir_u, u3_umon* mon_u) } } - free(pax_c); + c3_free(pax_c); } } } @@ -397,8 +397,8 @@ _unix_free_file(u3_ufil *fil_u) c3_assert(0); } - free(fil_u->pax_c); - free(fil_u); + c3_free(fil_u->pax_c); + c3_free(fil_u); } /* _unix_free_dir(): free directory, deleting everything within @@ -414,8 +414,8 @@ _unix_free_dir(u3_udir *dir_u) else { // fprintf(stderr, "i'm a lone, lonely loner %s\r\n", dir_u->pax_c); } - free(dir_u->pax_c); - free(dir_u); // XXX this might be too early, how do we + c3_free(dir_u->pax_c); + c3_free(dir_u); // XXX this might be too early, how do we // know we've freed all the children? // i suspect we should do this only if // our kid list is empty @@ -483,9 +483,9 @@ _unix_free_mount_point(u3_pier *pir_u, u3_umon* mon_u) nod_u = nex_u; } - free(mon_u->dir_u.pax_c); - free(mon_u->nam_c); - free(mon_u); + c3_free(mon_u->dir_u.pax_c); + c3_free(mon_u->nam_c); + c3_free(mon_u); } /* _unix_delete_mount_point(): remove mount point from list and free @@ -530,7 +530,7 @@ _unix_delete_mount_point(u3_pier *pir_u, u3_noun mon) _unix_free_mount_point(pir_u, tem_u); _delete_mount_point_out: - free(nam_c); + c3_free(nam_c); u3z(mon); } @@ -603,7 +603,7 @@ _unix_create_dir(u3_udir* dir_u, u3_udir* par_u, u3_noun nam) strncpy(pax_c + pax_w + 1, nam_c, nam_w); pax_c[pax_w + 1 + nam_w] = '\0'; - free(nam_c); + c3_free(nam_c); u3z(nam); _unix_mkdir(pax_c); @@ -666,18 +666,18 @@ _unix_update_file(u3_pier *pir_u, u3_ufil* fil_u) u3l_log("wrong # of bytes read in file %s: %d %d\r\n", fil_u->pax_c, len_ws, red_ws); } - free(dat_y); + c3_free(dat_y); return u3_nul; } else { c3_w mug_w = u3r_mug_bytes(dat_y, len_ws); if ( mug_w == fil_u->mug_w ) { - free(dat_y); + c3_free(dat_y); return u3_nul; } else if ( mug_w == fil_u->gum_w ) { fil_u->mug_w = mug_w; - free(dat_y); + c3_free(dat_y); return u3_nul; } else { @@ -687,7 +687,7 @@ _unix_update_file(u3_pier *pir_u, u3_ufil* fil_u) u3_noun mim = u3nt(c3__text, u3i_string("plain"), u3_nul); u3_noun dat = u3nt(mim, len_ws, u3i_bytes(len_ws, dat_y)); - free(dat_y); + c3_free(dat_y); return u3nc(u3nt(pax, u3_nul, dat), u3_nul); } } @@ -793,7 +793,7 @@ _unix_update_dir(u3_pier *pir_u, u3_udir* dir_u) if ( 0 != stat(pax_c, &buf_u) ) { u3l_log("can't stat %s: %s\r\n", pax_c, strerror(errno)); - free(pax_c); + c3_free(pax_c); continue; } else { @@ -823,7 +823,7 @@ _unix_update_dir(u3_pier *pir_u, u3_udir* dir_u) || ('#' == out_u->d_name[0] && '#' == out_u->d_name[strlen(out_u->d_name) - 1]) ) { - free(pax_c); + c3_free(pax_c); continue; } @@ -838,7 +838,7 @@ _unix_update_dir(u3_pier *pir_u, u3_udir* dir_u) } } - free(pax_c); + c3_free(pax_c); } } @@ -932,7 +932,7 @@ _unix_initial_update_file(c3_c* pax_c, c3_c* bas_c) u3l_log("wrong # of bytes read in initial file %s: %d %d\r\n", pax_c, len_ws, red_ws); } - free(dat_y); + c3_free(dat_y); return u3_nul; } else { @@ -942,7 +942,7 @@ _unix_initial_update_file(c3_c* pax_c, c3_c* bas_c) u3_noun mim = u3nt(c3__text, u3i_string("plain"), u3_nul); u3_noun dat = u3nt(mim, len_ws, u3i_bytes(len_ws, dat_y)); - free(dat_y); + c3_free(dat_y); return u3nc(u3nt(pax, u3_nul, dat), u3_nul); } } @@ -987,7 +987,7 @@ _unix_initial_update_dir(c3_c* pax_c, c3_c* bas_c) if ( 0 != stat(pox_c, &buf_u) ) { u3l_log("initial can't stat %s: %s\r\n", pox_c, strerror(errno)); - free(pox_c); + c3_free(pox_c); continue; } else { @@ -997,7 +997,7 @@ _unix_initial_update_dir(c3_c* pax_c, c3_c* bas_c) else { can = u3kb_weld(_unix_initial_update_file(pox_c, bas_c), can); } - free(pox_c); + c3_free(pox_c); } } } @@ -1045,7 +1045,7 @@ _unix_sync_file(u3_pier *pir_u, u3_udir* par_u, u3_noun nam, u3_noun ext, u3_nou strncpy(pax_c + par_w + 1 + nam_w + 1, ext_c, ext_w); pax_c[par_w + 1 + nam_w + 1 + ext_w] = '\0'; - free(nam_c); free(ext_c); + c3_free(nam_c); c3_free(ext_c); u3z(nam); u3z(ext); // check whether we already know about this file @@ -1079,7 +1079,7 @@ _unix_sync_file(u3_pier *pir_u, u3_udir* par_u, u3_noun nam, u3_noun ext, u3_nou } } - free(pax_c); + c3_free(pax_c); _unix_sync_file_out: u3z(mim); @@ -1261,7 +1261,7 @@ u3_unix_acquire(c3_c* pax_c) } fclose(loq_u); - free(paf_c); + c3_free(paf_c); } /* u3_unix_release(): release a lockfile. @@ -1272,7 +1272,7 @@ u3_unix_release(c3_c* pax_c) c3_c* paf_c = _unix_down(pax_c, ".vere.lock"); unlink(paf_c); - free(paf_c); + c3_free(paf_c); } /* u3_unix_ef_bake(): initial effects for new process. diff --git a/pkg/urbit/vere/walk.c b/pkg/urbit/vere/walk.c index e3af728b2..1456d9aa8 100644 --- a/pkg/urbit/vere/walk.c +++ b/pkg/urbit/vere/walk.c @@ -57,12 +57,12 @@ u3_walk_safe(c3_c* pas_c) close(fid_i); if ( fln_w != red_w ) { - free(pad_y); + c3_free(pad_y); return 0; } else { u3_noun pad = u3i_bytes(fln_w, (c3_y *)pad_y); - free(pad_y); + c3_free(pad_y); return pad; } @@ -89,12 +89,12 @@ u3_walk_load(c3_c* pas_c) close(fid_i); if ( fln_w != red_w ) { - free(pad_y); + c3_free(pad_y); return u3m_bail(c3__fail); } else { u3_noun pad = u3i_bytes(fln_w, (c3_y *)pad_y); - free(pad_y); + c3_free(pad_y); return pad; } @@ -130,7 +130,7 @@ _walk_mkdirp(c3_c* bas_c, u3_noun pax) } _walk_mkdirp(pax_c, u3t(pax)); - free(pax_c); + c3_free(pax_c); } /* u3_walk_save(): save file or bail. @@ -160,7 +160,7 @@ u3_walk_save(c3_c* pas_c, u3_noun tim, u3_atom pad, c3_c* bas_c, u3_noun pax) rit_w = write(fid_i, pad_y, fln_w); close(fid_i); - free(pad_y); + c3_free(pad_y); if ( rit_w != fln_w ) { u3l_log("%s: %s\n", pas_c, strerror(errno)); @@ -218,7 +218,7 @@ _walk_in(const c3_c* dir_c, c3_w len_w) pat_c[lef_w] = '\0'; if ( 0 != stat(pat_c, &buf_b) ) { - free(pat_c); + c3_free(pat_c); } else { u3_noun tim = c3_stat_mtime(&buf_b); @@ -244,8 +244,8 @@ _walk_in(const c3_c* dir_c, c3_w len_w) get = u3kdb_put(get, ext, u3nt(c3y, hax, dat)); map = u3kdb_put(map, nam, u3nc(c3n, get)); } - free(nam_c); - free(ext_c); + c3_free(nam_c); + c3_free(ext_c); } else { u3_noun dir = _walk_in(pat_c, lef_w); @@ -256,7 +256,7 @@ _walk_in(const c3_c* dir_c, c3_w len_w) } else u3z(tim); } - free(pat_c); + c3_free(pat_c); } } } diff --git a/pkg/urbit/worker/main.c b/pkg/urbit/worker/main.c index 8a290aabb..ba5d2806e 100644 --- a/pkg/urbit/worker/main.c +++ b/pkg/urbit/worker/main.c @@ -169,7 +169,7 @@ _worker_prof(FILE* fil_u, c3_w den, u3_noun mas) { c3_c* lab_c = u3m_pretty(h_mas); fprintf(fil_u, "h_mas: %s", lab_c); - free(lab_c); + c3_free(lab_c); } return tot_w; } @@ -179,7 +179,7 @@ _worker_prof(FILE* fil_u, c3_w den, u3_noun mas) { c3_c* lab_c = u3m_pretty(h_mas); fprintf(fil_u, "%s: ", lab_c); - free(lab_c); + c3_free(lab_c); } u3_noun it_mas, tt_mas; @@ -277,7 +277,7 @@ _worker_grab(u3_noun sac, u3_noun ovo, u3_noun vir) fil_u = fopen(man_c, "w"); fprintf(fil_u, "%s\r\n", wen_c); - free(wen_c); + c3_free(wen_c); u3z(wen); } #else @@ -668,7 +668,7 @@ _worker_work_live(c3_d evt_d, u3_noun job) clr_w, txt_c, evt_d, ms_w, (int) (d0.tv_usec % 1000) / 10); } - free(txt_c); + c3_free(txt_c); } #endif @@ -831,7 +831,7 @@ _worker_poke_exit(c3_w cod_w) // exit code fil_u = fopen(man_c, "w"); - free(wen_c); + c3_free(wen_c); u3z(wen); }