]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Partial implementation of mallinfo() (Ilpo Ruotsalainen)
authorJulian Seward <jseward@acm.org>
Wed, 26 Jun 2002 17:08:01 +0000 (17:08 +0000)
committerJulian Seward <jseward@acm.org>
Wed, 26 Jun 2002 17:08:01 +0000 (17:08 +0000)
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@470

coregrind/vg_clientfuncs.c
vg_clientfuncs.c

index 436ee259720962fb0c53cb668e30609007a976c4..ee4cf38e360a8af3a73966193a5c35af4dd0fdc3 100644 (file)
@@ -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 <malloc.h> 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;
 }
 
 
index 436ee259720962fb0c53cb668e30609007a976c4..ee4cf38e360a8af3a73966193a5c35af4dd0fdc3 100644 (file)
@@ -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 <malloc.h> 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;
 }