From: Julian Seward Date: Wed, 26 Jun 2002 17:08:01 +0000 (+0000) Subject: Partial implementation of mallinfo() (Ilpo Ruotsalainen) X-Git-Tag: svn/VALGRIND_1_0_3~30 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2ccd1ed4e9ee64d08059ee43ad905855c90e84ca;p=thirdparty%2Fvalgrind.git Partial implementation of mallinfo() (Ilpo Ruotsalainen) git-svn-id: svn://svn.valgrind.org/valgrind/trunk@470 --- diff --git a/coregrind/vg_clientfuncs.c b/coregrind/vg_clientfuncs.c index 436ee25972..ee4cf38e36 100644 --- a/coregrind/vg_clientfuncs.c +++ b/coregrind/vg_clientfuncs.c @@ -341,11 +341,34 @@ void malloc_get_state ( void ) void malloc_set_state ( void ) { VG_(panic)("call to malloc_set_state\n"); } -void* mallinfo ( void ) -{ - VG_(message)(Vg_UserMsg, - "Warning: incorrectly-handled call to mallinfo()"); - return NULL; + +/* Yet another ugly hack. Cannot include because we + implement functions implemented there with different signatures. + This struct definition MUST match the system one. */ + +/* SVID2/XPG mallinfo structure */ +struct mallinfo { + int arena; /* total space allocated from system */ + int ordblks; /* number of non-inuse chunks */ + int smblks; /* unused -- always zero */ + int hblks; /* number of mmapped regions */ + int hblkhd; /* total space in mmapped regions */ + int usmblks; /* unused -- always zero */ + int fsmblks; /* unused -- always zero */ + int uordblks; /* total allocated space */ + int fordblks; /* total non-inuse space */ + int keepcost; /* top-most, releasable (via malloc_trim) space */ +}; + +struct mallinfo mallinfo ( void ) +{ + /* Should really try to return something a bit more meaningful */ + Int i; + struct mallinfo mi; + UChar* pmi = (UChar*)(&mi); + for (i = 0; i < sizeof(mi); i++) + pmi[i] = 0; + return mi; } diff --git a/vg_clientfuncs.c b/vg_clientfuncs.c index 436ee25972..ee4cf38e36 100644 --- a/vg_clientfuncs.c +++ b/vg_clientfuncs.c @@ -341,11 +341,34 @@ void malloc_get_state ( void ) void malloc_set_state ( void ) { VG_(panic)("call to malloc_set_state\n"); } -void* mallinfo ( void ) -{ - VG_(message)(Vg_UserMsg, - "Warning: incorrectly-handled call to mallinfo()"); - return NULL; + +/* Yet another ugly hack. Cannot include because we + implement functions implemented there with different signatures. + This struct definition MUST match the system one. */ + +/* SVID2/XPG mallinfo structure */ +struct mallinfo { + int arena; /* total space allocated from system */ + int ordblks; /* number of non-inuse chunks */ + int smblks; /* unused -- always zero */ + int hblks; /* number of mmapped regions */ + int hblkhd; /* total space in mmapped regions */ + int usmblks; /* unused -- always zero */ + int fsmblks; /* unused -- always zero */ + int uordblks; /* total allocated space */ + int fordblks; /* total non-inuse space */ + int keepcost; /* top-most, releasable (via malloc_trim) space */ +}; + +struct mallinfo mallinfo ( void ) +{ + /* Should really try to return something a bit more meaningful */ + Int i; + struct mallinfo mi; + UChar* pmi = (UChar*)(&mi); + for (i = 0; i < sizeof(mi); i++) + pmi[i] = 0; + return mi; }