mem: nicer fm_status() & fm_sums() output
authorAndrei Pelinescu-Onciul <andrei@iptel.org>
Thu, 8 Oct 2009 10:11:39 +0000 (12:11 +0200)
committerAndrei Pelinescu-Onciul <andrei@iptel.org>
Thu, 8 Oct 2009 10:11:39 +0000 (12:11 +0200)
Removed useless and confusing current file location information
(we are interested where the fragment was allocated from, and not
where the information is printed).

mem/f_malloc.c

index d457f9d..c49a252 100644 (file)
@@ -583,29 +583,34 @@ void fm_status(struct fm_block* qm)
        int memlog;
 
        memlog=cfg_get(core, core_cfg, memlog);
-       LOG(memlog, "fm_status (%p):\n", qm);
+       LOG_(DEFAULT_FACILITY, memlog, "fm_status: ", "fm_status (%p):\n", qm);
        if (!qm) return;
 
-       LOG(memlog, " heap size= %ld\n", qm->size);
+       LOG_(DEFAULT_FACILITY, memlog, "fm_status: ", " heap size= %ld\n",
+                       qm->size);
 #if defined(DBG_F_MALLOC) || defined(MALLOC_STATS)
-       LOG(memlog, " used= %lu, used+overhead=%lu, free=%lu\n",
+       LOG_(DEFAULT_FACILITY, memlog, "fm_status: ",
+                       " used= %lu, used+overhead=%lu, free=%lu\n",
                        qm->used, qm->real_used, qm->size-qm->real_used);
-       LOG(memlog, " max used (+overhead)= %lu\n", qm->max_real_used);
+       LOG_(DEFAULT_FACILITY, memlog, "fm_status: ",
+                       " max used (+overhead)= %lu\n", qm->max_real_used);
 #endif
        /*
-       LOG(memlog, "dumping all fragments:\n");
+       LOG_(DEFAULT_FACILITY, memlog, "fm_status: ", "dumping all fragments:\n");
        for (f=qm->first_frag, i=0;((char*)f<(char*)qm->last_frag) && (i<10);
                        f=FRAG_NEXT(f), i++){
-               LOG(memlog, "    %3d. %c  address=%x  size=%d\n", i, 
+               LOG_(DEFAULT_FACILITY, memlog, "fm_status: ",
+                               "    %3d. %c  address=%x  size=%d\n", i,
                                (f->u.reserved)?'a':'N',
                                (char*)f+sizeof(struct fm_frag), f->size);
 #ifdef DBG_F_MALLOC
-               LOG(memlog, "            %s from %s: %s(%d)\n",
+               LOG_(DEFAULT_FACILITY, memlog, "fm_status: ",
+                               "            %s from %s: %s(%d)\n",
                                (f->u.is_free)?"freed":"alloc'd", f->file, f->func, f->line);
 #endif
        }
 */
-       LOG(memlog, "dumping free list:\n");
+       LOG_(DEFAULT_FACILITY, memlog, "fm_status: ", "dumping free list:\n");
        for(h=0,i=0,size=0;h<F_HASH_SIZE;h++){
                unused=0;
                for (f=qm->free_hash[h].first,j=0; f;
@@ -613,14 +618,16 @@ void fm_status(struct fm_block* qm)
                        if (!FRAG_WAS_USED(f)){
                                unused++;
 #ifdef DBG_F_MALLOC
-                               LOG(memlog, "unused fragm.: hash = %3d, fragment %p,"
+                               LOG_(DEFAULT_FACILITY, memlog, "fm_status: ",
+                                                       "unused fragm.: hash = %3d, fragment %p,"
                                                        " address %p size %lu, created from %s: %s(%ld)\n",
                                                    h, f, (char*)f+sizeof(struct fm_frag), f->size,
                                                        f->file, f->func, f->line);
 #endif
                        };
                }
-               if (j) LOG(memlog, "hash = %3d fragments no.: %5d, unused: %5d\n\t\t"
+               if (j) LOG_(DEFAULT_FACILITY, memlog, "fm_status: ",
+                                                       "hash = %3d fragments no.: %5d, unused: %5d\n\t\t"
                                                        " bucket size: %9lu - %9lu (first %9lu)\n",
                                                        h, j, unused, UN_HASH(h),
                                                ((h<=F_MALLOC_OPTIMIZE/ROUNDTO)?1:2)* UN_HASH(h),
@@ -632,7 +639,8 @@ void fm_status(struct fm_block* qm)
                }
                /*
                {
-                       LOG(memlog, "   %5d.[%3d:%3d] %c  address=%x  size=%d(%x)\n",
+                       LOG_(DEFAULT_FACILITY, memlog, "fm_status: ",
+                                       "   %5d.[%3d:%3d] %c  address=%x  size=%d(%x)\n",
                                        i, h, j,
                                        (f->u.reserved)?'a':'N',
                                        (char*)f+sizeof(struct fm_frag), f->size, f->size);
@@ -643,8 +651,10 @@ void fm_status(struct fm_block* qm)
                }
        */
        }
-       LOG(memlog, "TOTAL: %6d free fragments = %6lu free bytes\n", i, size);
-       LOG(memlog, "-----------------------------\n");
+       LOG_(DEFAULT_FACILITY, memlog, "fm_status: ",
+                       "TOTAL: %6d free fragments = %6lu free bytes\n", i, size);
+       LOG_(DEFAULT_FACILITY, memlog, "fm_status: ",
+                       "-----------------------------\n");
 }
 
 
@@ -756,7 +766,8 @@ void fm_sums(struct fm_block* qm)
        if (!qm) return;
 
        memlog=cfg_get(core, core_cfg, memlog);
-       LOG(memlog, "summarizing all alloc'ed. fragments:\n");
+       LOG_(DEFAULT_FACILITY, memlog, "fm_status: ",
+                       "summarizing all alloc'ed. fragments:\n");
        
        for (f=qm->first_frag, i=0; (char*)f<(char*)qm->last_frag;
                        f=FRAG_NEXT(f), i++){
@@ -777,7 +788,8 @@ void fm_sums(struct fm_block* qm)
        }
        x = root;
        while(x){
-               LOG(memlog, " count=%6d size=%10lu bytes from %s: %s(%ld)\n",
+               LOG_(DEFAULT_FACILITY, memlog, "fm_status: ",
+                               " count=%6d size=%10lu bytes from %s: %s(%ld)\n",
                        x->count,x->size,
                        x->file, x->func, x->line
                        );
@@ -785,7 +797,8 @@ void fm_sums(struct fm_block* qm)
                free(x);
                x = root;
        }
-       LOG(memlog, "-----------------------------\n");
+       LOG_(DEFAULT_FACILITY, memlog, "fm_status: ",
+                       "-----------------------------\n");
 }
 #endif /* DBG_F_MALLOC */