xfs
[Top] [All Lists]

Re: [PATCH 08/11] xfsprogs: replace obsolete memalign with posix_memalig

To: Jan Tulak <jtulak@xxxxxxxxxx>
Subject: Re: [PATCH 08/11] xfsprogs: replace obsolete memalign with posix_memalign
From: Christoph Hellwig <hch@xxxxxxxxxxxxx>
Date: Mon, 17 Aug 2015 12:36:24 -0700
Cc: xfs@xxxxxxxxxxx, hch@xxxxxxxxxxxxx
Delivered-to: xfs@xxxxxxxxxxx
In-reply-to: <1439828606-7886-9-git-send-email-jtulak@xxxxxxxxxx>
References: <1439828606-7886-1-git-send-email-jtulak@xxxxxxxxxx> <1439828606-7886-9-git-send-email-jtulak@xxxxxxxxxx>
User-agent: Mutt/1.5.23 (2014-03-12)
On Mon, Aug 17, 2015 at 06:23:23PM +0200, Jan Tulak wrote:
> Memalign from <malloc.h> was marked obsolete in favor of a posix
> variant from <stdlib.h>. So replace all calls and remove <malloc.h>
> includes. This also enhances support on other posix platforms,
> which doesn't have <malloc.h>.
> 
> Because posix_memalign returns any error as a return code, not in
> errno, change relevant checks in code (and add a missing one).

I have to say I hate the posix_memalign calling convention.  Any chance
you could just provide a memalign impementation using posix_memalign for
MacOS?

Something like:

static inline void *memalign(size_t alignment, size_t size)
{
        int error;
        void *buf;

        error = posix_memalign(&buf, alignment, size);
        if (error)
                errno = error;
                buf = NULL;
        }

        return buf;
}

<Prev in Thread] Current Thread [Next in Thread>