diff options
Diffstat (limited to 'wrapper/rvs.h')
-rw-r--r-- | wrapper/rvs.h | 31 |
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 |