|
|
@ -1204,13 +1204,13 @@ int32_t zeroval() { return(0); } |
|
|
|
void *LP_alloc(uint64_t len) |
|
|
|
{ |
|
|
|
struct LP_memory_list *mp; |
|
|
|
mp = calloc(1,sizeof(*mp)); |
|
|
|
mp = calloc(1,sizeof(*mp) + len); |
|
|
|
//if ( len == 72 )
|
|
|
|
// printf("%d\n",1/zeroval());
|
|
|
|
//printf("\n>>>>>>>>>>> LP_alloc mp.%p ptr.%p len.%llu\n",mp,mp->ptr,(long long)len);
|
|
|
|
mp->timestamp = (uint32_t)time(NULL); |
|
|
|
mp->len = (uint32_t)len; |
|
|
|
mp->ptr = calloc(1,len); |
|
|
|
mp->ptr = &mp[1]; |
|
|
|
portable_mutex_lock(&LP_cJSONmutex); |
|
|
|
DL_APPEND(LP_memory_list,mp); |
|
|
|
portable_mutex_unlock(&LP_cJSONmutex); |
|
|
@ -1225,7 +1225,8 @@ void *LP_realloc(void *ptr,uint64_t len) |
|
|
|
void LP_free(void *ptr) |
|
|
|
{ |
|
|
|
static uint32_t lasttime,unknown; |
|
|
|
uint32_t now; char str[65]; int32_t n,lagging; uint64_t total = 0; struct LP_memory_list *mp,*tmp; |
|
|
|
uint32_t now; char str[65]; int32_t n,lagging; uint64_t total = 0; struct LP_memory_list *mp,*tmp,*freemp = ptr; |
|
|
|
--freemp; |
|
|
|
if ( (now= (uint32_t)time(NULL)) > lasttime+6 ) |
|
|
|
{ |
|
|
|
n = lagging = 0; |
|
|
@ -1234,11 +1235,11 @@ void LP_free(void *ptr) |
|
|
|
{ |
|
|
|
total += mp->len; |
|
|
|
n++; |
|
|
|
if ( now > mp->timestamp+600 ) |
|
|
|
if ( now > mp->timestamp+60 ) |
|
|
|
{ |
|
|
|
lagging++; |
|
|
|
DL_DELETE(LP_memory_list,mp); |
|
|
|
free(mp->ptr); |
|
|
|
//free(mp->ptr);
|
|
|
|
free(mp); |
|
|
|
} |
|
|
|
} |
|
|
@ -1258,7 +1259,7 @@ void LP_free(void *ptr) |
|
|
|
DL_DELETE(LP_memory_list,mp); |
|
|
|
portable_mutex_unlock(&LP_cJSONmutex); |
|
|
|
//printf(">>>>>>>>>>> LP_free ptr.%p mp.%p len.%u\n",ptr,mp,mp->len);
|
|
|
|
free(mp->ptr); |
|
|
|
//free(mp->ptr);
|
|
|
|
free(mp); |
|
|
|
} else unknown++; // free from source file with #define redirect for alloc that wasnt
|
|
|
|
} |
|
|
|