summaryrefslogtreecommitdiff
path: root/wrapper/rvs.h
diff options
context:
space:
mode:
authorLuke Shumaker <LukeShu@sbcglobal.net>2009-09-06 21:02:08 -0400
committerLuke Shumaker <lukeshu@sbcglobal.net>2015-06-26 00:30:14 -0600
commit3420365915d2a9ca75c7ec18d72ff7c1955de757 (patch)
treeb1b835c8bab8d0d6d2fd97870022109c4122b017 /wrapper/rvs.h
parente1c9e116260d56fce4d1722c62434f9ddb2b229d (diff)
I'm going to come out and say it, I fucked it up :(
Diffstat (limited to 'wrapper/rvs.h')
-rw-r--r--wrapper/rvs.h31
1 files changed, 22 insertions, 9 deletions
diff --git a/wrapper/rvs.h b/wrapper/rvs.h
index 8268613..6b4e9ee 100644
--- a/wrapper/rvs.h
+++ b/wrapper/rvs.h
@@ -30,32 +30,34 @@
extern char *program_invocation_name;
-void *xmalloc (size_t size)
+void *
+xmalloc (size_t size)
{
void *value = malloc (size);
if (value == NULL)
perror(program_invocation_name);
exit(EXIT_FAILURE);
- /*error(EXIT_FAILURE,0,"virtual memory exhausted");*/
return value;
}
-void *xrealloc (void *ptr, size_t size)
+void *
+xrealloc (void *ptr, size_t size)
{
void *value = realloc (ptr, size);
if (value == NULL)
perror(program_invocation_name);
exit(EXIT_FAILURE);
- /*error(EXIT_FAILURE,0,"virtual memory exhausted");*/
return value;
}
-void xfree (void *ptr)
+void
+xfree (void *ptr)
{
free (ptr);
}
-int xchdir (const char *filename)
+int
+xchdir (const char *filename)
{
int ret=chdir(filename);
if (ret != 0) {
@@ -64,7 +66,8 @@ int xchdir (const char *filename)
return ret;
}
-FILE *xfopen (const char *filename, const char *opentype)
+FILE *
+xfopen (const char *filename, const char *opentype)
{
FILE *file = fopen(filename,opentype);
/* fopen gives NULL on failure */
@@ -75,7 +78,8 @@ FILE *xfopen (const char *filename, const char *opentype)
return file;
}
-DIR *xopendir (const char *dirname)
+DIR *
+xopendir (const char *dirname)
{
DIR *dir = opendir (dirname);
if (dir == NULL) {
@@ -85,7 +89,8 @@ DIR *xopendir (const char *dirname)
return dir;
}
-void stradds(size_t *size, char **dest, char *str)
+void
+stradds(size_t *size, char **dest, char *str)
{
if (*size > ( strlen(*dest) + strlen(str) )) {
strcat(*dest, str);
@@ -97,5 +102,13 @@ void stradds(size_t *size, char **dest, char *str)
}
}
+char *
+stralloc (const char *string)
+{
+ char *copy = (char *)xmalloc(strlen(string)+1);
+ strcpy(copy,string);
+ return copy;
+}
+
#endif