xfsprogs: Replace valloc with posix_memalign
[openwrt/openwrt.git] / package / utils / xfsprogs / patches / 130-db-malloc-Use-posix_memalign-instead-of-deprecated-v.patch
1 From 930f9aa8f08759fa739dd6e615ba8b3a1890008d Mon Sep 17 00:00:00 2001
2 From: Rosen Penev <rosenp@gmail.com>
3 Date: Mon, 6 May 2019 13:56:13 -0700
4 Subject: [PATCH] db/malloc: Use posix_memalign instead of deprecated valloc
5
6 valloc is not available with uClibc-ng as well as being deprecated, which
7 causes compilation errors. aligned_alloc is not available before C11 so
8 used posix_memalign.'
9
10 Signed-off-by: Rosen Penev <rosenp@gmail.com>
11 ---
12 db/malloc.c | 3 +--
13 1 file changed, 1 insertion(+), 2 deletions(-)
14
15 diff --git a/db/malloc.c b/db/malloc.c
16 index 77b3e022..38fe0b05 100644
17 --- a/db/malloc.c
18 +++ b/db/malloc.c
19 @@ -56,8 +56,7 @@ xmalloc(
20 {
21 void *ptr;
22
23 - ptr = valloc(size);
24 - if (ptr)
25 + if(!posix_memalign(&ptr, sysconf(_SC_PAGESIZE), size))
26 return ptr;
27 badmalloc();
28 /* NOTREACHED */
29 --
30 2.17.1
31