Tracking memory leaks is improving

This commit is contained in:
Quentin 2019-05-09 11:39:03 +02:00
parent 163110c814
commit 9685885afe
4 changed files with 9 additions and 2 deletions

View file

@ -306,6 +306,10 @@ int algo_rr_on_err(struct evt_core_ctx* ctx, struct evt_core_fdinfo* fdinfo) {
return 0;
}
void algo_rr_free(void* v) {
struct rr_ctx* rr = v;
free(rr);
}
void algo_rr_init(struct evt_core_ctx* ctx, struct algo_ctx* app_ctx, struct algo_params* ap) {
struct rr_ctx* rr = malloc(sizeof(struct rr_ctx));
@ -321,6 +325,7 @@ void algo_rr_init(struct evt_core_ctx* ctx, struct algo_ctx* app_ctx, struct alg
rr->recv_id = 0;
rr->recv_id_late = 0;
app_ctx->misc = rr;
app_ctx->free_misc = algo_rr_free;
init_timer(ctx);
}

View file

@ -5,8 +5,10 @@ void free_naive(void* app_ctx) {
struct algo_ctx* ctx = (struct algo_ctx*) app_ctx;
ctx->ref_count--;
if (ctx->ref_count > 0) return;
if (ctx->free_misc) ctx->free_misc(ctx->misc);
g_queue_free(ctx->free_buffer);
g_queue_free(ctx->read_waiting);
g_hash_table_destroy (ctx->application_waiting);
g_hash_table_destroy (ctx->used_buffer);
g_hash_table_destroy (ctx->write_waiting);
free(ctx);

View file

@ -3,7 +3,7 @@
void free_udp_t(void* v) {
struct udp_target* udp_t = v;
udp_t->ref_count--;
if (udp_t <= 0) {
if (udp_t->ref_count <= 0) {
free(udp_t);
}
}

View file

@ -187,7 +187,7 @@ void algo_main_init(struct evt_core_ctx* evt, struct algo_params* ap) {
.name = "tcp-listen",
.flags = EPOLLIN,
.app_ctx = ctx,
.free_app_ctx = free_nothing,
.free_app_ctx = free_naive,
.cb = main_on_tcp_co,
.err_cb = NULL
};