aboutsummaryrefslogtreecommitdiffstats
path: root/cmd/zpool/zpool_util.c
diff options
context:
space:
mode:
authorнаб <[email protected]>2021-05-20 23:02:44 +0200
committerBrian Behlendorf <[email protected]>2021-05-26 14:50:59 -0700
commita281f7690da598964168f4100571cc39b93a8cab (patch)
tree9d0fca9917ba65ce1bb977cf706bdf267ccf5120 /cmd/zpool/zpool_util.c
parent31f4c8cb19bf3f7a1629e259af77d8a63f3816fd (diff)
zpool: import: use realloc for realloc, remove strtok
Reviewed-by: Brian Behlendorf <[email protected]> Reviewed-by: John Kennedy <[email protected]> Signed-off-by: Ahelenia Ziemiańska <[email protected]> Closes #12094
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