diff options
| author | Jordan K. Hubbard <jkh@FreeBSD.org> | 1995-05-08 21:39:40 +0000 |
|---|---|---|
| committer | Jordan K. Hubbard <jkh@FreeBSD.org> | 1995-05-08 21:39:40 +0000 |
| commit | f9a1c2dee2a8d838307d572570aac3e589e05abb (patch) | |
| tree | bbc7db4913e184339a9fef242727b484f56afaa6 /usr.sbin/sysinstall/misc.c | |
| parent | 255aed5d9770e9888a3935a4e8985c0c2447f2ba (diff) | |
Notes
Diffstat (limited to 'usr.sbin/sysinstall/misc.c')
| -rw-r--r-- | usr.sbin/sysinstall/misc.c | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/usr.sbin/sysinstall/misc.c b/usr.sbin/sysinstall/misc.c index 794c49888fb6..500b4547a68c 100644 --- a/usr.sbin/sysinstall/misc.c +++ b/usr.sbin/sysinstall/misc.c @@ -1,7 +1,7 @@ /* * Miscellaneous support routines.. * - * $Id: misc.c,v 1.2 1995/04/29 19:33:04 jkh Exp $ + * $Id: misc.c,v 1.3 1995/05/01 21:56:27 jkh Exp $ * * Copyright (c) 1995 * Jordan Hubbard. All rights reserved. @@ -104,12 +104,28 @@ safe_malloc(size_t size) { void *ptr; + if (size <= 0) + msgFatal("Invalid malloc size of %d!", size); ptr = malloc(size); if (!ptr) msgFatal("Out of memory!"); return ptr; } +/* A realloc that checks errors */ +void * +safe_realloc(void *orig, size_t size) +{ + void *ptr; + + if (size <= 0) + msgFatal("Invalid realloc size of %d!", size); + ptr = realloc(orig, size); + if (!ptr) + msgFatal("Out of memory!"); + return ptr; +} + /* * These next routines are kind of specialized just for building string lists * for dialog_menu(). |
