4 Commits

Author SHA1 Message Date
Masatake YAMATO
b4f98f3d1f Define macros for renaming xmalloc and xcalloc
I'm planning to link strace with libiberty for mangling C++
symbol names in stack trace enabled with -k option.

Both names, xmalloc and xcalloc, are already defined and used
in libiberty, and they conflict with functions in strace.
Rename xmalloc and xcalloc functions defined in strace
to strace_xmalloc and strace_xcalloc, respectively,
to avoid this conflict.

* xmalloc.h (xcalloc, xmalloc): New macros.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2017-12-26 21:36:49 +00:00
Eugene Syromiatnikov
057a8f2274 xmalloc.c: introduce xgrowarray helper function
In order to simplify dynamic array management code.

* xmalloc.h (xgrowarray): New declaration.
* xmalloc.c (xgrowarray): New function.
2017-12-14 00:05:04 +00:00
Eugene Syromiatnikov
7ba0d89c9f xstrdup, xtrndup: allow NULL argument
Accept NULL argument in xstrdup and xtrndup functions to allow use
of "xstrdup(str)" instead of "str ? xstrdup(str) : NULL".

* xmalloc.c (xstrdup, xstrndup): Handle NULL argument.
* xmalloc.h: Add comment regarding this deviation from the behaviour
of the POSIX counterparts of these functions.
2017-08-24 20:06:54 +02:00
Edgar Kaziakhmedov
b4f16886e7 Move err/mem subroutines to separate files
In order to allow usage of utility functions by other binaries
included in the strace package (like the upcoming asinfo utility),
these functions should be moved to separate files.

* error_prints.h: New file.
* xmalloc.h: Likewise.
* defs.h: Include "xmalloc.h" and "error_prints.h".
(error_msg, error_msg_and_die, error_msg_and_help, perror_msg,
perror_msg_and_die): Move to error_prints.h.
(xcalloc, xmalloc, xreallocarray, xstrdup, xstrndup): Move to xmalloc.h.
* strace.c (die): Remove static quialifier to make visible
by error_prints.c.
(error_msg, error_msg_and_die, error_msg_and_help, perror_msg,
perror_msg_and_die, verror_msg): Move ...
* error_prints.c: ... to the new file.
* xmalloc.c: Include "config.h", <stdlib.h>, <string.h>,
"error_prints.h", and "xmalloc.h" instead of "defs.h".
Use int instead of bool.  Fix codestyle.
* Makefile.am (strace_SOURCES): Add error_prints.c, error_prints.h,
and xmalloc.h.

Signed-off-by: Edgar Kaziakhmedov <edgar.kaziakhmedov@virtuozzo.com>
Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
2017-08-07 10:59:22 +00:00