Ignore:
Timestamp:
Dec 13, 2001, 4:32:57 PM (24 years ago)
Author:
sandervl
Message:

added statistics

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/odincrt/malloc.cpp

    r5090 r7627  
    1 /* $Id: malloc.cpp,v 1.5 2001-02-11 10:32:51 sandervl Exp $ */
     1/* $Id: malloc.cpp,v 1.6 2001-12-13 15:32:17 sandervl Exp $ */
    22/*
    33 * Project Odin Software License can be found in LICENSE.TXT
     
    2020void * _IMPORT _LNK_CONV _debug_ucalloc(Heap_t , size_t, size_t ,const char *,size_t);
    2121
     22#ifdef DEBUG
     23unsigned long nrcalls_malloc = 0;
     24unsigned long nrcalls_free   = 0;
     25unsigned long totalmemalloc  = 0;
     26
     27void _LNK_CONV getcrtstat(unsigned long *pnrcalls_malloc,
     28                          unsigned long *pnrcalls_free,
     29                          unsigned long *ptotalmemalloc)
     30{
     31    *pnrcalls_malloc = nrcalls_malloc;
     32    *pnrcalls_free   = nrcalls_free;
     33    *ptotalmemalloc  = totalmemalloc;
     34}
     35#endif
     36
    2237void * _LNK_CONV os2calloc( size_t a, size_t b )
    2338{
     
    2540    void *rc;
    2641
     42#ifdef DEBUG
     43        totalmemalloc += a*b;
     44        nrcalls_malloc++;
     45#endif
    2746        rc = calloc(a,b);
    2847        SetFS(sel);
     
    3453    unsigned short sel = RestoreOS2FS();
    3554
     55#ifdef DEBUG
     56        nrcalls_free++;
     57        totalmemalloc -= _msize(a);
     58#endif
    3659        free(a);
    3760        SetFS(sel);
     
    4366    void *rc;
    4467
     68
     69#ifdef DEBUG
     70        totalmemalloc += a;
     71        nrcalls_malloc++;
     72#endif
    4573        rc = malloc(a);
    4674        SetFS(sel);
     
    5381    void *rc;
    5482
     83#ifdef DEBUG
     84        totalmemalloc += (b - _msize(a));
     85#endif
     86
    5587        rc = realloc(a, b);
    5688        SetFS(sel);
     
    6395    void *rc;
    6496
     97#ifdef DEBUG
     98        totalmemalloc += a*b;
     99        nrcalls_malloc++;
     100#endif
     101
    65102        rc = _debug_calloc(a,b,c,d);
    66103        SetFS(sel);
     
    72109    unsigned short sel = RestoreOS2FS();
    73110
     111
     112#ifdef DEBUG
     113        nrcalls_free++;
     114        totalmemalloc -= _msize(a);
     115#endif
    74116        _debug_free(a,b,c);
    75117        SetFS(sel);
     
    81123    void *rc;
    82124
     125#ifdef DEBUG
     126        totalmemalloc += a;
     127        nrcalls_malloc++;
     128#endif
    83129        rc = _debug_calloc(1,a,b,c);
    84130        SetFS(sel);
     
    91137    void *rc;
    92138
     139#ifdef DEBUG
     140        totalmemalloc += (b - _msize(a));
     141#endif
    93142        rc = _debug_realloc(a,b,c,d);
    94143        SetFS(sel);
     
    101150    void *rc;
    102151
     152#ifdef DEBUG
     153        totalmemalloc += b;
     154        nrcalls_malloc++;
     155#endif
    103156        rc = _umalloc(a,b);
    104157        SetFS(sel);
     
    111164    void *rc;
    112165
     166#ifdef DEBUG
     167        totalmemalloc += b*c;
     168        nrcalls_malloc++;
     169#endif
    113170        rc = _ucalloc(a,b,c);
    114171        SetFS(sel);
     
    121178    void *rc;
    122179
     180#ifdef DEBUG
     181        totalmemalloc += b;
     182        nrcalls_malloc++;
     183#endif
    123184        rc = _debug_ucalloc(a, 1, b,c,d);
    124185        SetFS(sel);
     
    131192    void *rc;
    132193
     194#ifdef DEBUG
     195        totalmemalloc += b*c;
     196        nrcalls_malloc++;
     197#endif
    133198        rc = _debug_ucalloc(a,b,c,d,e);
    134199        SetFS(sel);
Note: See TracChangeset for help on using the changeset viewer.