From patchwork Tue Jul 7 12:00:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Martin_Li=C5=A1ka?= X-Patchwork-Id: 39932 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2A59D38618E8; Tue, 7 Jul 2020 12:00:11 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by sourceware.org (Postfix) with ESMTPS id 24D723861817 for ; Tue, 7 Jul 2020 12:00:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 24D723861817 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=mliska@suse.cz X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 911F5AE44 for ; Tue, 7 Jul 2020 12:00:04 +0000 (UTC) From: =?utf-8?q?Martin_Li=C5=A1ka?= Subject: [PATCH] Use size_t for mallinfo fields. To: libc-alpha@sourceware.org Message-ID: Date: Tue, 7 Jul 2020 14:00:02 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.9.0 MIME-Version: 1.0 Content-Language: en-US X-Spam-Status: No, score=-9.8 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" 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(-) 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).