summaryrefslogtreecommitdiff
path: root/c/rvs.h
diff options
context:
space:
mode:
authorLuke Shumaker <LukeShu@sbcglobal.net>2009-09-03 19:38:20 -0400
committerLuke Shumaker <lukeshu@sbcglobal.net>2015-06-26 00:30:14 -0600
commit67d3b5846d84d4a2e5a31d4e268bc9d51495d7e0 (patch)
tree92db2e7852b7ee09e55a68276101566c562a4283 /c/rvs.h
parent1eacc442394d1f70bbe05dea699c80ca41f26d4c (diff)
the C implementation properly loads the plugins, then creates a dependancy tree
Diffstat (limited to 'c/rvs.h')
-rw-r--r--c/rvs.h29
1 files changed, 22 insertions, 7 deletions
diff --git a/c/rvs.h b/c/rvs.h
index 1bcbacf..5301b09 100644
--- a/c/rvs.h
+++ b/c/rvs.h
@@ -18,6 +18,8 @@
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
+#include <stdio.h>
+#include <dirent.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
@@ -26,20 +28,34 @@
void *xmalloc (size_t size)
{
- register void *value = malloc (size);
- if (value == 0)
+ void *value = malloc (size);
+ if (value == NULL)
error(EXIT_FAILURE,0,"virtual memory exhausted");
return value;
}
void *xrealloc (void *ptr, size_t size)
{
- register void *value = realloc (ptr, size);
- if (value == 0)
+ void *value = realloc (ptr, size);
+ if (value == NULL)
error(EXIT_FAILURE,0,"virtual memory exhausted");
return value;
}
+void xfree (void *ptr)
+{
+ free (ptr);
+}
+
+int xchdir (const char *filename)
+{
+ int ret=chdir(filename);
+ if (ret != 0) {
+ error(EXIT_FAILURE,errno,"%s/",filename);
+ }
+ return ret;
+}
+
FILE *xfopen (const char *filename, const char *opentype)
{
FILE *file = fopen(filename,opentype);
@@ -68,9 +84,8 @@ void stradds(size_t *size, char **dest, char *str)
} else {
*size = strlen(*dest) + strlen(str) + 1;
- char *string;
- string = (char *) xrealloc (*dest, *size);
- strcat(string, str);
+ *dest = (char *) xrealloc (*dest, *size);
+ strcat(*dest, str);
}
}