00001 #include <string.h>
00002 #include <stdlib.h>
00003 #include "dbmi.h"
00004
00011 char *
00012 db_store(char *s)
00013 {
00014 char *a;
00015
00016 a = db_malloc (strlen(s) + 1);
00017 if (a)
00018 strcpy (a, s);
00019 return a;
00020 }
00021
00028 void *
00029 db_malloc(int n)
00030 {
00031 void *s;
00032
00033 if (n <= 0)
00034 n = 1;
00035 s = malloc((unsigned int) n);
00036 if (s == NULL)
00037 db_memory_error ();
00038 return s;
00039 }
00040
00047 void *
00048 db_calloc(int n, int m)
00049 {
00050 void *s;
00051
00052 if (n <= 0)
00053 n = 1;
00054 if (m <= 0)
00055 m = 1;
00056 s = calloc((unsigned int) n, (unsigned int) m);
00057 if (s == NULL)
00058 db_memory_error ();
00059 return s;
00060 }
00061
00068 void *
00069 db_realloc(void *s, int n)
00070 {
00071 if (n <= 0)
00072 n = 1;
00073 if(s == NULL)
00074 s = malloc((unsigned int) n);
00075 else
00076 s = realloc (s, (unsigned int) n);
00077 if (s == NULL)
00078 db_memory_error ();
00079 return s;
00080 }