Browse Source

ckdb - fix some memory leaks

master
kanoi 9 years ago
parent
commit
90a11f3681
  1. 4
      src/ckdb.c
  2. 3
      src/ckdb.h
  3. 9
      src/ckdb_data.c
  4. 14
      src/ckdb_dbio.c
  5. 2
      src/klist.c
  6. 4
      src/ktree.c

4
src/ckdb.c

@ -1882,7 +1882,9 @@ static void dealloc_storage()
FREE_TREE(events_hash);
FREE_LISTS(events);
FREE_ALL(ovents);
FREE_ALL(ips);
FREE_TREE(ips);
FREE_STORE_DATA(ips);
FREE_LIST(ips);
FREE_ALL(auths);
FREE_TREE(payouts_wid);

3
src/ckdb.h

@ -52,7 +52,7 @@
#define DB_VLOCK "1"
#define DB_VERSION "1.0.5"
#define CKDB_VERSION DB_VERSION"-2.104"
#define CKDB_VERSION DB_VERSION"-2.105"
#define WHERE_FFL " - from %s %s() line %d"
#define WHERE_FFL_HERE __FILE__, __func__, __LINE__
@ -2803,6 +2803,7 @@ extern void free_users_data(K_ITEM *item);
extern void free_workinfo_data(K_ITEM *item);
extern void free_sharesummary_data(K_ITEM *item);
extern void free_payouts_data(K_ITEM *item);
extern void free_ips_data(K_ITEM *item);
extern void free_optioncontrol_data(K_ITEM *item);
extern void free_markersummary_data(K_ITEM *item);
extern void free_workmarkers_data(K_ITEM *item);

9
src/ckdb_data.c

@ -73,6 +73,15 @@ void free_payouts_data(K_ITEM *item)
FREENULL(payouts->stats);
}
void free_ips_data(K_ITEM *item)
{
IPS *ips;
DATA_IPS(ips, item);
LIST_MEM_SUB(ips_free, ips->description);
FREENULL(ips->description);
}
void free_sharesummary_data(K_ITEM *item)
{
SHARESUMMARY *sharesummary;

14
src/ckdb_dbio.c

@ -2981,6 +2981,8 @@ bool optioncontrol_fill(PGconn *conn)
K_WUNLOCK(optioncontrol_free);
PQclear(res);
for (n = 0; n < par; n++)
free(params[n]);
if (ok) {
LOGDEBUG("%s(): built", __func__);
@ -3384,7 +3386,9 @@ bool workinfo_fill(PGconn *conn)
flail:
res = PQexec(conn, "Commit", CKPQ_READ);
PQclear(res);
for (n = 0; n < par; n++)
free(params[n]);
free(sel);
if (ok) {
LOGDEBUG("%s(): built", __func__);
@ -7053,7 +7057,9 @@ void ips_add(char *group, char *ip, char *eventname, bool is_event, char *des,
STRNCPY(ips->ip, ip);
STRNCPY(ips->eventname, eventname);
ips->is_event = is_event;
if (des) {
if (!des)
ips->description = NULL;
else {
ips->description = strdup(des);
if (!ips->description)
quithere(1, "strdup OOM");
@ -7081,7 +7087,9 @@ void ips_add(char *group, char *ip, char *eventname, bool is_event, char *des,
}
}
if (ok) {
if (des) {
if (!des)
ips2->description = NULL;
else {
ips2->description = strdup(des);
LIST_MEM_ADD(ips_free, ips2->description);
}

2
src/klist.c

@ -1,6 +1,6 @@
/*
* Copyright 2013-2014 Andrew Smith - BlackArrow Ltd
* Copyright 2015 Andrew Smith
* Copyright 2015-2016 Andrew Smith
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free

4
src/ktree.c

@ -1,5 +1,5 @@
/*
* Copyright 1995-2015 Andrew Smith
* Copyright 1995-2016 Andrew Smith
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
@ -1097,4 +1097,6 @@ void _free_ktree(K_TREE *tree, void (*free_funct)(void *), KTREE_FFL_ARGS)
tree->node_store = k_free_store(tree->node_store);
tree->node_free = k_free_list(tree->node_free);
free(tree);
}

Loading…
Cancel
Save