Make out-of-memory handling more uniform
This fixes one real bug in dumpstr().
* defs.h: Declare die_out_of_memory().
* strace.c (die_out_of_memory): New function.
(strace_popen): If allocation fails, call die_out_of_memory().
(main): Likewise.
(expand_tcbtab): Likewise.
(rebuild_pollv): Likewise.
* count.c (count_syscall): Likewise.
(call_summary_pers): Likewise.
* desc.c (decode_select): Likewise.
* file.c (sys_getdents): Likewise.
(sys_getdents64): Likewise.
(sys_getdirentries): Likewise.
* pathtrace.c (pathtrace_match): Likewise.
* syscall.c (qualify): Likewise.
* util.c (printstr): Likewise.
(dumpiov): Likewise.
(dumpstr): Likewise.
(fixvfork): Likewise.
* mem.c (sys_mincore): Don't check free() parameter for NULL.
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
diff --git a/syscall.c b/syscall.c
index f8c4c8b..b21ce01 100644
--- a/syscall.c
+++ b/syscall.c
@@ -473,10 +473,8 @@
qualify_one(i, opt->bitflag, !not, -1);
}
copy = strdup(s);
- if (!copy) {
- fprintf(stderr, "out of memory\n");
- exit(1);
- }
+ if (!copy)
+ die_out_of_memory();
for (p = strtok(copy, ","); p; p = strtok(NULL, ",")) {
if (opt->bitflag == QUAL_TRACE && (n = lookup_class(p)) > 0) {
for (i = 0; i < nsyscalls0; i++)