chunk mem leak, and undiagnose chunk code

This commit is contained in:
Olof Hagsand 2017-02-03 00:04:49 +01:00
parent c9190eee44
commit 30a479de68
3 changed files with 18 additions and 17 deletions

View file

@ -39,10 +39,9 @@
/*
* Compile with chunk diagnostics. XXX Should be in Makefile.in ??
*/
#define CHUNK_DIAG
#undef CHUNK_DIAG
/*
* Base number of bits to shift getting the size of a chunk_head.
@ -165,7 +164,7 @@ char *_chunk_sprintf (const char *, const char *, int, const char *, ...);
#else /* CHUNK_DIAG */
void *chunk (size_t, const char *);
void *rechunk (void *, size_t, const char *);
void *chunkdup (void *, size_t, const char *);
void *chunkdup (const void *, size_t, const char *);
char *chunk_strncat (const char *, const char *, size_t, const char *);
char *chunk_sprintf (const char *, char *, ...);
#endif /* CHUNK_DIAG */

View file

@ -710,18 +710,13 @@ chunk_check(FILE *fout, const char *name)
chunk_group_t *grp = NULL;
chunk_grpent_t *ent;
if (!chunk_initialized)
return;
/* No name given, walk through everything
*/
if (name == (const char *)NULL) {
for (idx = 0; idx < CHUNK_HEADS; idx++) {
chunk_head_t *chead = &chunk_heads[idx];
cnk = chead->ch_cnks;
if (cnk == (chunk_t *)NULL)
continue;
@ -730,7 +725,7 @@ chunk_check(FILE *fout, const char *name)
/* If no file name it's an internal chunk */
if (cnk->c_diag.cd_file)
fprintf(fout ? fout : stdout,
clicon_debug(0,
"%s:%d,\t%zu bytes (%p), group \"%s\"\n",
cnk->c_diag.cd_file,
cnk->c_diag.cd_line,
@ -786,4 +781,9 @@ chunk_check(FILE *fout, const char *name)
} while (ent != grp->cg_ent);
}
}
#else /* CHUNK_DIAG */
void
chunk_check(FILE *fout, const char *name)
{
}
#endif /* CHUNK_DIAG */

View file

@ -707,6 +707,8 @@ get(char *dbname,
goto done;
/* Assume body is created at end of function */
}
free(argdec);
argdec = NULL;
break;
case Y_LIST:
/*
@ -1011,14 +1013,13 @@ xmldb_get_local(clicon_handle h,
/* If vectors are specified then filter out everything else,
* otherwise return complete tree.
*/
if (xvec != NULL)
for (i=0; i<xlen; i++)
xml_flag_set(xvec[i], XML_FLAG_MARK);
if (xml_tree_prune_unmarked(xt, NULL) < 0)
goto done;
if (xml_apply(xt, CX_ELMNT, (xml_applyfn_t*)xml_flag_reset, (void*)XML_FLAG_MARK) < 0)
goto done;
if (xvec != NULL)
for (i=0; i<xlen; i++)
xml_flag_set(xvec[i], XML_FLAG_MARK);
if (xml_tree_prune_unmarked(xt, NULL) < 0)
goto done;
if (xml_apply(xt, CX_ELMNT, (xml_applyfn_t*)xml_flag_reset, (void*)XML_FLAG_MARK) < 0)
goto done;
if (xvec0 && xlen0){
*xvec0 = xvec;
xvec = NULL;
@ -1041,6 +1042,7 @@ xmldb_get_local(clicon_handle h,
free(dbname);
if (xvec)
free(xvec);
unchunk_group(__FUNCTION__);
return retval;
}