diff options
author | Mike Frysinger <vapier@gentoo.org> | 2008-12-31 07:13:17 -0500 |
---|---|---|
committer | Mike Frysinger <vapier@gentoo.org> | 2008-12-31 09:52:26 -0500 |
commit | c9f9ef7dc32c851b44f51b67912cf2d9a48b108f (patch) | |
tree | 4dc4420892900cd2799918055ccd517fb28eb039 /libsbutil/include | |
parent | libsandbox/libsbutil: link with -no-undefined (diff) | |
download | sandbox-c9f9ef7dc32c851b44f51b67912cf2d9a48b108f.tar.gz sandbox-c9f9ef7dc32c851b44f51b67912cf2d9a48b108f.tar.bz2 sandbox-c9f9ef7dc32c851b44f51b67912cf2d9a48b108f.zip |
libsbutil: cleanup x* memory functions
Pull the x* memory functions out of rcscripts and into libsbutil and change
their style to match the rest of sbutil. Also add xzalloc() and xstrdup(),
and convert pointless strndup() usage to strdup().
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Diffstat (limited to 'libsbutil/include')
-rw-r--r-- | libsbutil/include/rcscripts/rcutil.h | 2 | ||||
-rw-r--r-- | libsbutil/include/rcscripts/util/debug.h | 25 | ||||
-rw-r--r-- | libsbutil/include/rcscripts/util/str_list.h | 2 | ||||
-rw-r--r-- | libsbutil/include/rcscripts/util/string.h | 3 |
4 files changed, 3 insertions, 29 deletions
diff --git a/libsbutil/include/rcscripts/rcutil.h b/libsbutil/include/rcscripts/rcutil.h index 895a141..248b84a 100644 --- a/libsbutil/include/rcscripts/rcutil.h +++ b/libsbutil/include/rcscripts/rcutil.h @@ -18,4 +18,6 @@ #include "rcscripts/util/str_list.h" /* used by libsandbox/execve wrapper */ +#include "sbutil.h" + #endif /* __RCUTIL_H__ */ diff --git a/libsbutil/include/rcscripts/util/debug.h b/libsbutil/include/rcscripts/util/debug.h index a9f3e7b..8bc2371 100644 --- a/libsbutil/include/rcscripts/util/debug.h +++ b/libsbutil/include/rcscripts/util/debug.h @@ -14,10 +14,6 @@ #include <errno.h> #include <stdio.h> -#define save_errno() int old_errno = errno; -#define restore_errno() errno = old_errno; -#define saved_errno old_errno - void rc_log_domain (const char *new_domain); void @@ -115,25 +111,4 @@ bool __check_arg_fp (FILE * fp, const char *file, const char *func, size_t line) #define check_arg_fp(_fp) \ __check_arg_fp (_fp, __FILE__, __func__, __LINE__) -/* - * Various memory allocation functions and macro's. - * They set errno to ENOMEM and print debug info. - */ - -void *__xcalloc (size_t nmemb, size_t size, const char *file, const char *func, size_t line); -void *__xmalloc (size_t size, const char *file, const char *func, size_t line); -void *__xrealloc (void *ptr, size_t size, const char *file, const char *func, size_t line); - -#define xcalloc(_nmemb, _size) \ - __xcalloc (_nmemb, _size, __FILE__, __func__, __LINE__) -#define xmalloc(_size) \ - __xmalloc (_size, __FILE__, __func__, __LINE__) -#define xrealloc(_ptr, _size) \ - __xrealloc (_ptr, _size, __FILE__, __func__, __LINE__) - -char *__xstrndup (const char *str, size_t size, const char *file, const char *func, size_t line); - -#define xstrndup(_str, _size) \ - __xstrndup (_str, _size, __FILE__, __func__, __LINE__) - #endif /* __RC_DEBUG_H__ */ diff --git a/libsbutil/include/rcscripts/util/str_list.h b/libsbutil/include/rcscripts/util/str_list.h index 068f902..ac287db 100644 --- a/libsbutil/include/rcscripts/util/str_list.h +++ b/libsbutil/include/rcscripts/util/str_list.h @@ -64,7 +64,7 @@ goto _error; \ } \ _string_list = _tmp_p; \ - _tmp_str = xstrndup (_item, strlen (_item)); \ + _tmp_str = xstrdup (_item); \ if (NULL == _tmp_str) \ { \ goto _error; \ diff --git a/libsbutil/include/rcscripts/util/string.h b/libsbutil/include/rcscripts/util/string.h index 982d9a7..e7c1b2d 100644 --- a/libsbutil/include/rcscripts/util/string.h +++ b/libsbutil/include/rcscripts/util/string.h @@ -15,7 +15,4 @@ * with the malloc() call. */ char *rc_strcatpaths (const char *pathname1, const char *pathname2); -/* Compat functions for GNU extensions */ -char *rc_strndup (const char *str, size_t size); - #endif /* __RC_STRING_H__ */ |