summaryrefslogtreecommitdiff
path: root/c/rvs.h
diff options
context:
space:
mode:
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);
}
}