X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fvppinfra%2Fdlmalloc.c;h=16f2de0fc09647646446f6184775cc60cd2bfa49;hb=3f812aaf63c622bada7eae45e5b1cb14e89ba7ea;hp=8ae92cf566c0320f2cc53ad502111732412b8682;hpb=d3ca8ffd0f095b9649b43cca5bb65fb82df3bb2a;p=vpp.git diff --git a/src/vppinfra/dlmalloc.c b/src/vppinfra/dlmalloc.c index 8ae92cf566c..16f2de0fc09 100644 --- a/src/vppinfra/dlmalloc.c +++ b/src/vppinfra/dlmalloc.c @@ -1612,7 +1612,11 @@ static size_t traverse_and_check(mstate m); #if (FOOTERS && !INSECURE) /* Check if (alleged) mstate m has expected magic field */ -#define ok_magic(M) ((M)->magic == mparams.magic) +static inline int +ok_magic (const mstate m) +{ + return (m->magic == mparams.magic); +} #else /* (FOOTERS && !INSECURE) */ #define ok_magic(M) (1) #endif /* (FOOTERS && !INSECURE) */ @@ -2074,8 +2078,8 @@ static void do_check_malloc_state(mstate m) { /* ----------------------------- statistics ------------------------------ */ #if !NO_MALLINFO -static struct mallinfo internal_mallinfo(mstate m) { - struct mallinfo nm = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; +static struct dlmallinfo internal_mallinfo(mstate m) { + struct dlmallinfo nm = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; ensure_initialization(); if (!PREACTION(m)) { check_malloc_state(m); @@ -3959,7 +3963,7 @@ size_t dlmalloc_set_footprint_limit(size_t bytes) { } #if !NO_MALLINFO -struct mallinfo dlmallinfo(void) { +struct dlmallinfo dlmallinfo(void) { return internal_mallinfo(gm); } #endif /* NO_MALLINFO */ @@ -4116,6 +4120,10 @@ int mspace_is_heap_object (mspace msp, void *p) return 1; this_seg = this_seg->next; } + + if (pp > ms->least_addr && pp <= ms->least_addr + ms->footprint) + return 1; + return 0; } @@ -4271,6 +4279,14 @@ void mspace_put (mspace msp, void *p_arg) mheap_put_trace ((u64)p_arg, psize); } +#if CLIB_DEBUG > 0 + /* Poison the object */ + { + size_t psize = mspace_usable_size (object_header); + memset (object_header, 0x13, psize); + } +#endif + /* And free it... */ mspace_free (msp, object_header); } @@ -4765,7 +4781,7 @@ size_t mspace_set_footprint_limit(mspace msp, size_t bytes) { } #if !NO_MALLINFO -struct mallinfo mspace_mallinfo(mspace msp) { +struct dlmallinfo mspace_mallinfo(mspace msp) { mstate ms = (mstate)msp; if (!ok_magic(ms)) { USAGE_ERROR_ACTION(ms,ms);