summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpefo <>1997-08-23 10:43:25 +0000
committerpefo <>1997-08-23 10:43:25 +0000
commitd1992b87de38ede6e6dd8ba853ae384f5fbad27d (patch)
tree64d62f971edbbe1bd158f8d92b2dc8bcecfd7523
parent7cf0a9096ed9b087d6bf9c23fadee9eba456f4e3 (diff)
downloadopenbsd-d1992b87de38ede6e6dd8ba853ae384f5fbad27d.tar.gz
openbsd-d1992b87de38ede6e6dd8ba853ae384f5fbad27d.tar.bz2
openbsd-d1992b87de38ede6e6dd8ba853ae384f5fbad27d.zip
Change realloc(foo,0) to behave like malloc(0). Both now return a pointer
to an object of size zero. This will allow testing on reallocs return value to determine if the operation was successful or not.
-rw-r--r--src/lib/libc/stdlib/malloc.311
-rw-r--r--src/lib/libc/stdlib/malloc.c5
2 files changed, 8 insertions, 8 deletions
diff --git a/src/lib/libc/stdlib/malloc.3 b/src/lib/libc/stdlib/malloc.3
index eb09eeedbc..6fd362b93b 100644
--- a/src/lib/libc/stdlib/malloc.3
+++ b/src/lib/libc/stdlib/malloc.3
@@ -33,7 +33,7 @@
33.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34.\" SUCH DAMAGE. 34.\" SUCH DAMAGE.
35.\" 35.\"
36.\" $OpenBSD: malloc.3,v 1.6 1997/05/31 08:55:05 tholo Exp $ 36.\" $OpenBSD: malloc.3,v 1.7 1997/08/23 10:43:24 pefo Exp $
37.\" 37.\"
38.Dd August 27, 1996 38.Dd August 27, 1996
39.Dt MALLOC 3 39.Dt MALLOC 3
@@ -77,6 +77,8 @@ coercion) for storage of any type of object. If the space is of
77.Em pagesize 77.Em pagesize
78or larger, the memory returned will be page-aligned. 78or larger, the memory returned will be page-aligned.
79.Pp 79.Pp
80Allocation of a zero size object returns a pointer to a zero size object.
81.Pp
80The 82The
81.Fn free 83.Fn free
82function causes the space pointed to by 84function causes the space pointed to by
@@ -120,7 +122,8 @@ If
120.Fa size 122.Fa size
121is zero and 123is zero and
122.Fa ptr 124.Fa ptr
123is not a null pointer, the object it points to is freed. 125is not a null pointer, the object it points to is freed and a new zero size
126object is returned.
124.Pp 127.Pp
125Malloc will first look for a symbolic link called 128Malloc will first look for a symbolic link called
126.Pa /etc/malloc.conf 129.Pa /etc/malloc.conf
@@ -211,8 +214,8 @@ function returns no value.
211.Pp 214.Pp
212The 215The
213.Fn realloc 216.Fn realloc
214function returns either a null pointer or a pointer 217function a pointer to the possibly moved allocated space;
215to the possibly moved allocated space. 218otherwise a null pointer is returned.
216.Sh MESSAGES 219.Sh MESSAGES
217If 220If
218.Fn malloc , 221.Fn malloc ,
diff --git a/src/lib/libc/stdlib/malloc.c b/src/lib/libc/stdlib/malloc.c
index 12cc67083d..66d1a2a9da 100644
--- a/src/lib/libc/stdlib/malloc.c
+++ b/src/lib/libc/stdlib/malloc.c
@@ -8,7 +8,7 @@
8 */ 8 */
9 9
10#if defined(LIBC_SCCS) && !defined(lint) 10#if defined(LIBC_SCCS) && !defined(lint)
11static char rcsid[] = "$OpenBSD: malloc.c,v 1.28 1997/08/22 17:06:59 deraadt Exp $"; 11static char rcsid[] = "$OpenBSD: malloc.c,v 1.29 1997/08/23 10:43:25 pefo Exp $";
12#endif /* LIBC_SCCS and not lint */ 12#endif /* LIBC_SCCS and not lint */
13 13
14/* 14/*
@@ -1234,9 +1234,6 @@ realloc(void *ptr, size_t size)
1234 } 1234 }
1235 if (!ptr) { 1235 if (!ptr) {
1236 r = imalloc(size); 1236 r = imalloc(size);
1237 } else if (ptr && !size) {
1238 ifree(ptr);
1239 r = 0;
1240 } else { 1237 } else {
1241 r = irealloc(ptr, size); 1238 r = irealloc(ptr, size);
1242 } 1239 }