Added: ndbuf_free_item() function to free in a proper way e.g.
free allocated stuff via escan function.
This commit is contained in:
parent
fb41052802
commit
68aa01d300
@ -178,4 +178,7 @@ int ndbuf_cmp(ndbuf_t *, ndbuf_t *);
|
||||
*/
|
||||
int ndbuf_memopt(ndbuf_t *);
|
||||
|
||||
/* free in a right way: freing allocated memory during escan */
|
||||
void ndbuf_free_item(ndbuf_t *b, void *ip, size_t is);
|
||||
|
||||
#endif /* __NDBUF_H__ */
|
||||
|
17
ndbuf.c
17
ndbuf.c
@ -913,4 +913,21 @@ int ndbuf_memopt(ndbuf_t *b)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ndbuf_free_item(ndbuf_t *b, void *ip, size_t is)
|
||||
{
|
||||
if(!b || !ip) return;
|
||||
|
||||
if(__is_moless(b->flags)) return;
|
||||
|
||||
if(__is_usermo(b->flags)) {
|
||||
if((b->flags & NDBUF_BURN) && (is > 0)) b->mop->zero(ip, is);
|
||||
b->mop->free(ip);
|
||||
} else {
|
||||
if((b->flags & NDBUF_BURN) && (is > 0)) memset(ip, 0, is);
|
||||
free(ip);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
#undef DEFAULT_PREALLOC_SIZE
|
||||
|
Loading…
x
Reference in New Issue
Block a user