zpool: import: use realloc for realloc, remove strtok

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: John Kennedy <john.kennedy@delphix.com>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #12094
This commit is contained in:
наб
2021-05-20 23:02:44 +02:00
committed by Brian Behlendorf
parent 31f4c8cb19
commit a281f7690d
3 changed files with 29 additions and 32 deletions
+16
View File
@@ -49,6 +49,22 @@ safe_malloc(size_t size)
return (data);
}
/*
* 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.
*/