Module: sip-router
Branch: master
Commit: a7d59baca2d03b48f020b10adf6e6e614494a35e
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=a7d59ba…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: Sat May 3 22:13:16 2014 +0200
core/mem: f_malloc - groupped few updates of usage stats in insert free function
---
mem/f_malloc.c | 11 +++--------
1 files changed, 3 insertions(+), 8 deletions(-)
diff --git a/mem/f_malloc.c b/mem/f_malloc.c
index 026ff39..4c3576a 100644
--- a/mem/f_malloc.c
+++ b/mem/f_malloc.c
@@ -289,6 +289,7 @@ void fm_split_frag(struct fm_block* qm, struct fm_frag* frag,
FRAG_CLEAR_USED(n); /* never used */
/* new frag overhead */
qm->real_used+=FRAG_OVERHEAD;
+ qm->used-=FRAG_OVERHEAD;
#ifdef DBG_F_MALLOC
/* frag created by malloc, mark it*/
n->file=file;
@@ -342,8 +343,8 @@ struct fm_block* fm_malloc_init(char* address, unsigned long size, int
type)
qm=(struct fm_block*)start;
memset(qm, 0, sizeof(struct fm_block));
qm->size=size;
- qm->used = size;
- qm->real_used=size + init_overhead;
+ qm->used = size - init_overhead;
+ qm->real_used=size;
qm->max_real_used=init_overhead;
qm->type = type;
size-=init_overhead;
@@ -678,10 +679,6 @@ void* fm_realloc(struct fm_block* qm, void* p, unsigned long size)
#else
fm_split_frag(qm, f, size);
#endif
- /* fm_split frag already adds FRAG_OVERHEAD for the newly created
- free frag, so here we only need orig_size-f->size for real used */
- qm->real_used-=(orig_size-f->size);
- qm->used-=(orig_size-f->size);
}else if (f->size<size){
/* grow */
#ifdef DBG_F_MALLOC
@@ -723,8 +720,6 @@ void* fm_realloc(struct fm_block* qm, void* p, unsigned long size)
fm_split_frag(qm, f, size);
#endif
}
- qm->real_used+=(f->size-orig_size);
- qm->used+=(f->size-orig_size);
}else{
/* could not join => realloc */
#ifdef DBG_F_MALLOC