]> CyberLeo.Net >> Repos - SourceForge/afuse.git/blob - src/utils.c
Refactored some data structures into their own source modules for clarity.
[SourceForge/afuse.git] / src / utils.c
1 #define __UTILS_C
2
3 #include <stdlib.h>
4 #include <stdio.h>
5 #include <string.h>
6 #include "utils.h"
7
8 void *my_malloc(size_t size)
9 {
10         void *p;
11
12         p = malloc(size);
13
14         if(!p) {
15                 fprintf(stderr, "Failed to allocate: %d bytes of memory.\n");
16                 exit(1);
17         }
18
19         return p;
20 }
21
22 char *my_strdup(const char *str)
23 {
24         char *new_str;
25
26         new_str = my_malloc(strlen(str) + 1);
27         strcpy(new_str, str);
28
29         return new_str;
30 }