aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2007-10-04 17:26:57 +0000
committerRoy Marples <roy@marples.name>2007-10-04 17:26:57 +0000
commita6f2713002db20cd65618c1140ed7d3fbbbb9292 (patch)
tree09e8ad5903ba7472f5f01e410550e2e9c79367db /src
parentaf5525f6342c6ceda5913d2f6675d72ea8501ef3 (diff)
inline rc_xmalloc, rc_xrealloc and rc_xstrdup so that the library doesn't expose them.
Diffstat (limited to 'src')
-rw-r--r--src/librc-misc.c38
-rw-r--r--src/rc-misc.h39
-rw-r--r--src/rc.h21
-rw-r--r--src/rc.map3
4 files changed, 39 insertions, 62 deletions
diff --git a/src/librc-misc.c b/src/librc-misc.c
index 936fc730..f255f706 100644
--- a/src/librc-misc.c
+++ b/src/librc-misc.c
@@ -6,7 +6,6 @@
#include "librc.h"
-#define ERRX fprintf (stderr, "out of memory\n"); exit (1)
#define PROFILE_ENV "/etc/profile.env"
#define SYS_WHITELIST RC_LIBDIR "/conf.d/env_whitelist"
@@ -15,43 +14,6 @@
#define PATH_PREFIX RC_LIBDIR "/bin:/bin:/sbin:/usr/bin:/usr/sbin"
-void *rc_xmalloc (size_t size)
-{
- void *value = malloc (size);
-
- if (value)
- return (value);
-
- ERRX;
-}
-librc_hidden_def(rc_xmalloc)
-
-void *rc_xrealloc (void *ptr, size_t size)
-{
- void *value = realloc (ptr, size);
-
- if (value)
- return (value);
-
- ERRX;
-}
-librc_hidden_def(rc_xrealloc)
-
-char *rc_xstrdup (const char *str)
-{
- char *value;
-
- if (! str)
- return (NULL);
-
- value = strdup (str);
-
- if (value)
- return (value);
-
- ERRX;
-}
-librc_hidden_def(rc_xstrdup)
bool rc_env_bool (const char *var)
{
diff --git a/src/rc-misc.h b/src/rc-misc.h
index 40228b70..609447f7 100644
--- a/src/rc-misc.h
+++ b/src/rc-misc.h
@@ -41,6 +41,45 @@
/* Good defaults just incase user has none set */
#define RC_NET_FS_LIST_DEFAULT "afs cifs coda davfs fuse gfs ncpfs nfs nfs4 ocfs2 shfs smbfs"
+#define ERRX fprintf (stderr, "out of memory\n"); exit (1)
+
+static inline void *rc_xmalloc (size_t size)
+{
+ void *value = malloc (size);
+
+ if (value)
+ return (value);
+
+ ERRX;
+}
+
+static inline void *rc_xrealloc (void *ptr, size_t size)
+{
+ void *value = realloc (ptr, size);
+
+ if (value)
+ return (value);
+
+ ERRX;
+}
+
+static inline char *rc_xstrdup (const char *str)
+{
+ char *value;
+
+ if (! str)
+ return (NULL);
+
+ value = strdup (str);
+
+ if (value)
+ return (value);
+
+ ERRX;
+}
+
+#undef ERRX
+
static inline bool rc_exists (const char *pathname)
{
struct stat buf;
diff --git a/src/rc.h b/src/rc.h
index ddd54c67..414955e7 100644
--- a/src/rc.h
+++ b/src/rc.h
@@ -419,27 +419,6 @@ void rc_strlist_reverse (char **list);
* @param list to free */
void rc_strlist_free (char **list);
-/*! @name Memory Allocation
- * Ensure that if we cannot allocate the memory then we exit */
-/*@{*/
-
-/*! Allocate a block of memory
- * @param size of memory to allocate
- * @return pointer to memory */
-void *rc_xmalloc (size_t size);
-
-/*! Re-size a block of memory
- * @param ptr to the block of memory to re-size
- * @param size memory should be
- * @return pointer to memory block */
-void *rc_xrealloc (void *ptr, size_t size);
-
-/*! Duplicate a NULL terminated string
- * @param str to duplicate
- * @return pointer to the new string */
-char *rc_xstrdup (const char *str);
-/*@}*/
-
/*! @name Utility
* Although not RC specific functions, they are used by the supporting
* applications */
diff --git a/src/rc.map b/src/rc.map
index 6fb6220b..fa738c37 100644
--- a/src/rc.map
+++ b/src/rc.map
@@ -57,9 +57,6 @@ global:
rc_strlist_join;
rc_strlist_reverse;
rc_waitpid;
- rc_xmalloc;
- rc_xrealloc;
- rc_xstrdup;
local:
*;