aboutsummaryrefslogtreecommitdiffstats
path: root/cmd/zpool/zpool_util.c
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/zpool/zpool_util.c')
-rw-r--r--cmd/zpool/zpool_util.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/cmd/zpool/zpool_util.c b/cmd/zpool/zpool_util.c
index 1c1eb024f..1c64c83d8 100644
--- a/cmd/zpool/zpool_util.c
+++ b/cmd/zpool/zpool_util.c
@@ -50,6 +50,22 @@ safe_malloc(size_t size)
}
/*
+ * Utility function to guarantee realloc() success.
+ */
+void *
+safe_realloc(void *from, size_t size)
+{
+ void *data;
+
+ if ((data = realloc(from, size)) == NULL) {
+ (void) fprintf(stderr, "internal error: out of memory\n");
+ exit(1);
+ }
+
+ return (data);
+}
+
+/*
* Display an out of memory error message and abort the current program.
*/
void