1 /* SPDX-License-Identifier: MIT OR X11
3 * Copyright © 1987, 1998 The Open Group
4 * Copyright © 2024 Enrico Weigelt, metux IT consult <info@metux.net>
6 #include <dix-config.h>
13 XNFalloc(unsigned long amount
)
15 void *ptr
= malloc(amount
);
18 FatalError("Out of memory");
22 /* The original XNFcalloc was used with the xnfcalloc macro which multiplied
23 * the arguments at the call site without allowing calloc to check for overflow.
24 * XNFcallocarray was added to fix that without breaking ABI.
27 XNFcalloc(unsigned long amount
)
29 return XNFcallocarray(1, amount
);
33 XNFcallocarray(size_t nmemb
, size_t size
)
35 void *ret
= calloc(nmemb
, size
);
38 FatalError("XNFcalloc: Out of memory");
43 XNFrealloc(void *ptr
, unsigned long amount
)
45 void *ret
= realloc(ptr
, amount
);
48 FatalError("XNFrealloc: Out of memory");
53 XNFreallocarray(void *ptr
, size_t nmemb
, size_t size
)
55 void *ret
= reallocarray(ptr
, nmemb
, size
);
58 FatalError("XNFreallocarray: Out of memory");