public inbox for glibc-cvs@sourceware.org help / color / mirror / Atom feed
From: Szabolcs Nagy <nsz@sourceware.org> To: glibc-cvs@sourceware.org Subject: [glibc/arm/morello/main] malloc: Use uintptr_t for pointer alignment Date: Thu, 27 Oct 2022 13:49:09 +0000 (GMT) [thread overview] Message-ID: <20221027134919.E4418385151E@sourceware.org> (raw) https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=ada54f951a29c70e6bdba0c55e5e6ce4e2f65f27 commit ada54f951a29c70e6bdba0c55e5e6ce4e2f65f27 Author: Carlos Eduardo Seo <carlos.seo@arm.com> Date: Wed Jan 26 16:00:13 2022 -0300 malloc: Use uintptr_t for pointer alignment Avoid integer casts that assume unsigned long can represent pointers. Diff: --- malloc/arena.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/malloc/arena.c b/malloc/arena.c index 0a684a720d..b1f5b4117f 100644 --- a/malloc/arena.c +++ b/malloc/arena.c @@ -444,7 +444,7 @@ dump_heap (heap_info *heap) fprintf (stderr, "Heap %p, size %10lx:\n", heap, (long) heap->size); ptr = (heap->ar_ptr != (mstate) (heap + 1)) ? (char *) (heap + 1) : (char *) (heap + 1) + sizeof (struct malloc_state); - p = (mchunkptr) (((unsigned long) ptr + MALLOC_ALIGN_MASK) & + p = (mchunkptr) (((uintptr_t) ptr + MALLOC_ALIGN_MASK) & ~MALLOC_ALIGN_MASK); for (;; ) { @@ -518,7 +518,7 @@ alloc_new_heap (size_t size, size_t top_pad, size_t pagesize, p1 = (char *) MMAP (0, max_size << 1, PROT_NONE, mmap_flags); if (p1 != MAP_FAILED) { - p2 = (char *) (((unsigned long) p1 + (max_size - 1)) + p2 = (char *) (((uintptr_t) p1 + (max_size - 1)) & ~(max_size - 1)); ul = p2 - p1; if (ul) @@ -760,7 +760,7 @@ _int_new_arena (size_t size) /* Set up the top chunk, with proper alignment. */ ptr = (char *) (a + 1); - misalign = (unsigned long) chunk2mem (ptr) & MALLOC_ALIGN_MASK; + misalign = (uintptr_t) chunk2mem (ptr) & MALLOC_ALIGN_MASK; if (misalign > 0) ptr += MALLOC_ALIGNMENT - misalign; top (a) = (mchunkptr) ptr;
next reply other threads:[~2022-10-27 13:49 UTC|newest] Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-10-27 13:49 Szabolcs Nagy [this message] 2022-11-23 14:39 Szabolcs Nagy
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20221027134919.E4418385151E@sourceware.org \ --to=nsz@sourceware.org \ --cc=glibc-cvs@sourceware.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).