xref: /illumos-gate/usr/src/lib/libc/port/gen/reallocf.c (revision e7b66456)
1*e7b66456SAndy Fiddaman /*
2*e7b66456SAndy Fiddaman  * This file and its contents are supplied under the terms of the
3*e7b66456SAndy Fiddaman  * Common Development and Distribution License ("CDDL"), version 1.0.
4*e7b66456SAndy Fiddaman  * You may only use this file in accordance with the terms of version
5*e7b66456SAndy Fiddaman  * 1.0 of the CDDL.
6*e7b66456SAndy Fiddaman  *
7*e7b66456SAndy Fiddaman  * A full copy of the text of the CDDL should have accompanied this
8*e7b66456SAndy Fiddaman  * source. A copy of the CDDL is also available via the Internet at
9*e7b66456SAndy Fiddaman  * http://www.illumos.org/license/CDDL.
10*e7b66456SAndy Fiddaman  */
11*e7b66456SAndy Fiddaman 
12*e7b66456SAndy Fiddaman /*
13*e7b66456SAndy Fiddaman  * Copyright 2019 OmniOS Community Edition (OmniOSce) Association.
14*e7b66456SAndy Fiddaman  */
15*e7b66456SAndy Fiddaman 
16*e7b66456SAndy Fiddaman #include <stdlib.h>
17*e7b66456SAndy Fiddaman 
18*e7b66456SAndy Fiddaman void *
reallocf(void * ptr,size_t size)19*e7b66456SAndy Fiddaman reallocf(void *ptr, size_t size)
20*e7b66456SAndy Fiddaman {
21*e7b66456SAndy Fiddaman 	void *nptr = realloc(ptr, size);
22*e7b66456SAndy Fiddaman 
23*e7b66456SAndy Fiddaman 	/* If size is zero, realloc will have already freed ptr. */
24*e7b66456SAndy Fiddaman 	if (nptr == NULL && size != 0)
25*e7b66456SAndy Fiddaman 		free(ptr);
26*e7b66456SAndy Fiddaman 
27*e7b66456SAndy Fiddaman 	return (nptr);
28*e7b66456SAndy Fiddaman }
29