public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Use size_t for mallinfo fields.
@ 2020-07-07 12:00 Martin Liška
  2020-07-07 12:17 ` Andreas Schwab
  0 siblings, 1 reply; 39+ messages in thread
From: Martin Liška @ 2020-07-07 12:00 UTC (permalink / raw)
  To: libc-alpha

[-- Attachment #1: Type: text/plain, Size: 361 bytes --]

Hi.

The current int type can easily overflow for allocation of more
than 4GB.

The following patch changes that to size_t. I guess I need to adjust
the API version of the function, right?

Thanks,
Martin

---
  malloc/malloc.h    | 20 ++++++++++----------
  manual/memory.texi | 22 +++++++++++-----------
  2 files changed, 21 insertions(+), 21 deletions(-)



[-- Attachment #2: 0001-Use-size_t-for-mallinfo-fields.patch --]
[-- Type: text/x-patch, Size: 3018 bytes --]

diff --git a/malloc/malloc.h b/malloc/malloc.h
index a6903fdd54..785c38e164 100644
--- a/malloc/malloc.h
+++ b/malloc/malloc.h
@@ -85,16 +85,16 @@ __THROW __attribute_malloc__;
 
 struct mallinfo
 {
-  int arena;    /* non-mmapped space allocated from system */
-  int ordblks;  /* number of free chunks */
-  int smblks;   /* number of fastbin blocks */
-  int hblks;    /* number of mmapped regions */
-  int hblkhd;   /* space in mmapped regions */
-  int usmblks;  /* always 0, preserved for backwards compatibility */
-  int fsmblks;  /* space available in freed fastbin blocks */
-  int uordblks; /* total allocated space */
-  int fordblks; /* total free space */
-  int keepcost; /* top-most, releasable (via malloc_trim) space */
+  size_t arena;    /* non-mmapped space allocated from system */
+  size_t ordblks;  /* number of free chunks */
+  size_t smblks;   /* number of fastbin blocks */
+  size_t hblks;    /* number of mmapped regions */
+  size_t hblkhd;   /* space in mmapped regions */
+  size_t usmblks;  /* always 0, preserved for backwards compatibility */
+  size_t fsmblks;  /* space available in freed fastbin blocks */
+  size_t uordblks; /* total allocated space */
+  size_t fordblks; /* total free space */
+  size_t keepcost; /* top-most, releasable (via malloc_trim) space */
 };
 
 /* Returns a copy of the updated current mallinfo. */
diff --git a/manual/memory.texi b/manual/memory.texi
index aa5011e4f9..ac803dd2d5 100644
--- a/manual/memory.texi
+++ b/manual/memory.texi
@@ -1516,39 +1516,39 @@ This structure type is used to return information about the dynamic
 memory allocator.  It contains the following members:
 
 @table @code
-@item int arena
+@item size_t arena
 This is the total size of memory allocated with @code{sbrk} by
 @code{malloc}, in bytes.
 
-@item int ordblks
+@item size_t ordblks
 This is the number of chunks not in use.  (The memory allocator
-internally gets chunks of memory from the operating system, and then
+size_ternally gets chunks of memory from the operating system, and then
 carves them up to satisfy individual @code{malloc} requests;
 @pxref{The GNU Allocator}.)
 
-@item int smblks
+@item size_t smblks
 This field is unused.
 
-@item int hblks
+@item size_t hblks
 This is the total number of chunks allocated with @code{mmap}.
 
-@item int hblkhd
+@item size_t hblkhd
 This is the total size of memory allocated with @code{mmap}, in bytes.
 
-@item int usmblks
+@item size_t usmblks
 This field is unused and always 0.
 
-@item int fsmblks
+@item size_t fsmblks
 This field is unused.
 
-@item int uordblks
+@item size_t uordblks
 This is the total size of memory occupied by chunks handed out by
 @code{malloc}.
 
-@item int fordblks
+@item size_t fordblks
 This is the total size of memory occupied by free (not in use) chunks.
 
-@item int keepcost
+@item size_t keepcost
 This is the size of the top-most releasable chunk that normally
 borders the end of the heap (i.e., the high end of the virtual address
 space's data segment).


^ permalink raw reply	[flat|nested] 39+ messages in thread

end of thread, other threads:[~2020-09-21  8:49 UTC | newest]

Thread overview: 39+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-07 12:00 [PATCH] Use size_t for mallinfo fields Martin Liška
2020-07-07 12:17 ` Andreas Schwab
2020-07-07 13:07   ` Martin Liška
2020-07-07 13:19     ` H.J. Lu
2020-07-07 13:49     ` Florian Weimer
2020-07-07 13:52       ` Martin Liška
2020-07-07 14:22         ` Florian Weimer
2020-07-07 14:32           ` Andreas Schwab
2020-07-07 14:36             ` Florian Weimer
2020-07-08  7:25               ` Martin Liška
2020-07-08  7:24           ` Martin Liška
2020-07-23 10:23             ` Martin Liška
2020-07-23 14:38             ` Szabolcs Nagy
2020-07-27 12:08               ` Martin Liška
2020-07-27 12:21                 ` Florian Weimer
2020-07-27 12:45                   ` Martin Liška
2020-08-11 12:26                     ` Martin Liška
2020-08-11 13:44                     ` Florian Weimer
2020-08-11 17:08                       ` DJ Delorie
2020-08-12 12:29                         ` Martin Liška
2020-08-24  9:55                           ` Martin Liška
2020-08-28 19:05                             ` DJ Delorie
2020-08-31 13:35                               ` H.J. Lu
2020-08-31 13:56                                 ` Adhemerval Zanella
2020-08-31 14:00                                   ` H.J. Lu
2020-08-31 14:10                                     ` Adhemerval Zanella
2020-09-01 17:26                               ` Joseph Myers
2020-09-02 13:19                                 ` Martin Liška
2020-09-02 13:34                                   ` Adhemerval Zanella
2020-09-02 14:00                                   ` Carlos O'Donell
2020-09-02 16:11                                   ` DJ Delorie
2020-09-21  8:49                                     ` Martin Liška
2020-09-02 20:16                                 ` DJ Delorie
2020-09-02 20:24                                   ` Florian Weimer
2020-09-02 21:04                                     ` [PATCH/v2] " DJ Delorie
2020-09-03 11:17                                       ` Adhemerval Zanella
2020-09-03 21:33                                         ` DJ Delorie
2020-09-17 23:02                                         ` DJ Delorie
2020-09-02 20:25                                   ` [PATCH] " Joseph Myers

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).