replaced a ton of free or strdup calls for zap_safe_free and zap_strdup

git-svn-id: http://svn.openzap.org/svn/openzap/branches/sangoma_boost@864 a93c3328-9c30-0410-af19-c9cd2b2d52af
This commit is contained in:
Moises Silva
2009-11-16 14:52:02 +00:00
parent f3d2328564
commit 34307d8e52
16 changed files with 62 additions and 60 deletions

View File

@@ -73,7 +73,7 @@ create_hashtable(unsigned int minsize,
h = (struct hashtable *)zap_malloc(sizeof(struct hashtable));
if (NULL == h) return NULL; /*oom*/
h->table = (struct entry **)zap_malloc(sizeof(struct entry*) * size);
if (NULL == h->table) { free(h); return NULL; } /*oom*/
if (NULL == h->table) { zap_safe_free(h); return NULL; } /*oom*/
memset(h->table, 0, size * sizeof(struct entry *));
h->tablelength = size;
h->primeindex = pindex;
@@ -125,7 +125,7 @@ hashtable_expand(struct hashtable *h)
newtable[index] = e;
}
}
free(h->table);
zap_safe_free(h->table);
h->table = newtable;
}
/* Plan B: realloc instead */
@@ -236,7 +236,7 @@ hashtable_remove(struct hashtable *h, void *k)
if (e->flags & HASHTABLE_FLAG_FREE_KEY) {
freekey(e->k);
}
free(e);
zap_safe_free(e);
return v;
}
pE = &(e->next);
@@ -258,11 +258,11 @@ hashtable_destroy(struct hashtable *h)
{
e = table[i];
while (NULL != e)
{ f = e; e = e->next; if (f->flags & HASHTABLE_FLAG_FREE_KEY) freekey(f->k); if (f->flags & HASHTABLE_FLAG_FREE_VALUE) free(f->v); free(f); }
{ f = e; e = e->next; if (f->flags & HASHTABLE_FLAG_FREE_KEY) freekey(f->k); if (f->flags & HASHTABLE_FLAG_FREE_VALUE) zap_safe_free(f->v); zap_safe_free(f); }
}
free(h->table);
free(h);
zap_safe_free(h->table);
zap_safe_free(h);
}
OZ_DECLARE(struct hashtable_iterator *) hashtable_next(struct hashtable_iterator *i)