Date: Fri, 24 Feb 2023 19:08:36 -0500 From: Ed Maste <emaste@freebsd.org> To: Ed Maste <emaste@freebsd.org>, src-committers@freebsd.org, dev-commits-src-all@freebsd.org, dev-commits-src-main@freebsd.org Subject: Re: git: 2c709ee70ade - main - libc: handle zero alignment in memalign() Message-ID: <CAPyFy2D3T6AtK-TYU2HZ9R8QvemC%2B_2pZ52vqANoPOtHhnyuiw@mail.gmail.com> In-Reply-To: <20230224205001.Fbn1A%steffen@sdaoden.eu> References: <202302241821.31OIL4ux075893@gitrepo.freebsd.org> <20230224205001.Fbn1A%steffen@sdaoden.eu>
next in thread | previous in thread | raw e-mail | index | archive | help
On Fri, 24 Feb 2023 at 18:26, Steffen Nurpmeso <steffen@sdaoden.eu> wrote: > > Ed Maste wrote in > <202302241821.31OIL4ux075893@gitrepo.freebsd.org>: > |URL: https://cgit.FreeBSD.org/src/commit/?id=2c709ee70ade9fd8f77b37917a4\ > |169d667dda41d > ... > |commit 2c709ee70ade9fd8f77b37917a4169d667dda41d > |Author: Paul Floyd <pjfloyd@wanadoo.fr> > |AuthorDate: 2023-02-24 16:29:01 +0000 > |Commit: Ed Maste <emaste@FreeBSD.org> > |CommitDate: 2023-02-24 18:19:06 +0000 > | > | libc: handle zero alignment in memalign() > | > | For compatibility with glibc. The previous code would trigger a \ > | division > | by zero in roundup() and terminate. Instead, just pass through to > | malloc() for align == 0. > ... > |- return (aligned_alloc(align, roundup(size, align))); > |+ /* > |+ * glibc allows align == 0, but that is not valid for roundup. > |+ * Just pass through to malloc in that case. > |+ */ > |+ if (align != 0) > |+ return (aligned_alloc(align, roundup(size, align))); > |+ else > |+ return (malloc(size)); > > Just out of interest. Why not 1? > Or "if(align==0)align=1;"? Yes that's what I would have done, but it's fine either way and I just took the submission. > (Which is what i always did, as> "allocating nothing" is merely a debug concern, which, for better > memory pools like OpenBSD (i would presume), or during ASAN, > causes better (even upon read).) I don't really understand what you mean here, or how "allocating nothing" is related.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAPyFy2D3T6AtK-TYU2HZ9R8QvemC%2B_2pZ52vqANoPOtHhnyuiw>