[sr-dev] git:master:647a734f: core: mem - use macro for setting qm report fields
Daniel-Constantin Mierla
miconda at gmail.com
Thu Mar 10 11:19:40 CET 2022
Module: kamailio
Branch: master
Commit: 647a734f07537272f1235415f2712f770bc3f350
URL: https://github.com/kamailio/kamailio/commit/647a734f07537272f1235415f2712f770bc3f350
Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2022-03-10T11:19:26+01:00
core: mem - use macro for setting qm report fields
---
Modified: src/core/mem/q_malloc.c
---
Diff: https://github.com/kamailio/kamailio/commit/647a734f07537272f1235415f2712f770bc3f350.diff
Patch: https://github.com/kamailio/kamailio/commit/647a734f07537272f1235415f2712f770bc3f350.patch
---
diff --git a/src/core/mem/q_malloc.c b/src/core/mem/q_malloc.c
index 69de680d76..2ff295fcb1 100644
--- a/src/core/mem/q_malloc.c
+++ b/src/core/mem/q_malloc.c
@@ -1028,6 +1028,14 @@ void qm_sums(void* qmp)
"-----------------------------\n");
}
+#define QM_REPORT_SET(MREP, FRAG, FIELD) do { \
+ MREP->FIELD ## _size = FRAG->size; \
+ MREP->FIELD ## _file = FRAG->file; \
+ MREP->FIELD ## _func = FRAG->func; \
+ MREP->FIELD ## _mname = FRAG->mname; \
+ MREP->FIELD ## _line = FRAG->line; \
+ } while(0)
+
void qm_report(void* qmp, mem_report_t *mrep)
{
struct qm_block* qm;
@@ -1050,67 +1058,34 @@ void qm_report(void* qmp, mem_report_t *mrep)
mrep->free_frags++;
mrep->free_size_m += f->size;
if(mrep->max_free_frag_size==0) {
- mrep->max_free_frag_size = f->size;
- mrep->max_free_frag_file = f->file;
- mrep->max_free_frag_func = f->func;
- mrep->max_free_frag_mname = f->mname;
- mrep->max_free_frag_line = f->line;
+ QM_REPORT_SET(mrep, f, max_free_frag);
} else {
if(f->size > mrep->max_free_frag_size) {
- mrep->max_free_frag_size = f->size;
- mrep->max_free_frag_file = f->file;
- mrep->max_free_frag_func = f->func;
- mrep->max_free_frag_mname = f->mname;
- mrep->max_free_frag_line = f->line;
+ QM_REPORT_SET(mrep, f, max_free_frag);
}
}
if(mrep->min_free_frag_size==0) {
- mrep->min_free_frag_size = f->size;
- mrep->min_free_frag_file = f->file;
- mrep->min_free_frag_func = f->func;
- mrep->min_free_frag_mname = f->mname;
- mrep->min_free_frag_line = f->line;
+ QM_REPORT_SET(mrep, f, min_free_frag);
} else {
if(f->size < mrep->min_free_frag_size) {
- mrep->min_free_frag_size = f->size;
- mrep->min_free_frag_file = f->file;
- mrep->min_free_frag_func = f->func;
- mrep->min_free_frag_mname = f->mname;
- mrep->min_free_frag_line = f->line;
+ QM_REPORT_SET(mrep, f, min_free_frag);
}
}
} else {
mrep->used_frags++;
mrep->used_size_m += f->size;
if(mrep->max_used_frag_size==0) {
- mrep->max_used_frag_size = f->size;
- mrep->max_used_frag_file = f->file;
- mrep->max_used_frag_func = f->func;
- mrep->max_used_frag_mname = f->mname;
- mrep->max_used_frag_line = f->line;
+ QM_REPORT_SET(mrep, f, max_used_frag);
} else {
if(f->size > mrep->max_used_frag_size) {
- mrep->max_used_frag_size = f->size;
- mrep->max_used_frag_size = f->size;
- mrep->max_used_frag_file = f->file;
- mrep->max_used_frag_func = f->func;
- mrep->max_used_frag_mname = f->mname;
- mrep->max_used_frag_line = f->line;
+ QM_REPORT_SET(mrep, f, max_used_frag);
}
}
if(mrep->min_used_frag_size==0) {
- mrep->min_used_frag_size = f->size;
- mrep->min_used_frag_file = f->file;
- mrep->min_used_frag_func = f->func;
- mrep->min_used_frag_mname = f->mname;
- mrep->min_used_frag_line = f->line;
+ QM_REPORT_SET(mrep, f, min_used_frag);
} else {
if(f->size < mrep->min_used_frag_size) {
- mrep->min_used_frag_size = f->size;
- mrep->min_used_frag_file = f->file;
- mrep->min_used_frag_func = f->func;
- mrep->min_used_frag_mname = f->mname;
- mrep->min_used_frag_line = f->line;
+ QM_REPORT_SET(mrep, f, min_used_frag);
}
}
}
More information about the sr-dev
mailing list