/[anubis]/anubis/src/mem.c
ViewVC logotype

Diff of /anubis/src/mem.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.2 by gray, Mon Feb 17 20:52:57 2003 UTC revision 1.3 by polak, Tue Jul 15 13:48:09 2003 UTC
# Line 29  xmalloc(int n) Line 29  xmalloc(int n)
29  {  {
30          void *p;          void *p;
31    
32          p = (void *)malloc(n);          p = malloc(n);
33          if (p == 0) {          if (p == NULL) {
34                  anubis_error(HARD,                  anubis_error(HARD,
35                          _("malloc() failed. Cannot allocate enough memory."));                          _("malloc() failed. Cannot allocate enough memory."));
36                  quit(EXIT_FAILURE); /* force exit */                  quit(EXIT_FAILURE); /* force exit */
37          }          }
38          else          memset(p, 0, n);
                 memset(p, 0, n);  
39          return p;          return p;
40  }  }
41    
42  void *  void *
43  xrealloc(void *p, int n)  xrealloc(void *p, int n)
44  {  {
45          if (p == 0)          if (p == NULL)
46                  return xmalloc(n);                  return xmalloc(n);
47    
48          p = (void *)realloc(p, n);          p = realloc(p, n);
49          if (p == 0) {          if (p == NULL) {
50                  anubis_error(HARD,                  anubis_error(HARD,
51                          _("realloc() failed. Cannot reallocate enough memory."));                          _("realloc() failed. Cannot reallocate enough memory."));
52                  quit(EXIT_FAILURE); /* force exit */                  quit(EXIT_FAILURE); /* force exit */
# Line 58  xrealloc(void *p, int n) Line 57  xrealloc(void *p, int n)
57  char *  char *
58  allocbuf(char *s, int maxsize)  allocbuf(char *s, int maxsize)
59  {  {
60          char *p = 0;          char *p = NULL;
61          int len;          int len;
62    
63          if (s == 0)          if (s == NULL)
64                  return 0;                  return NULL;
65    
66          len = strlen(s);          len = strlen(s);
67          if (maxsize != 0) {          if (maxsize != 0) {
# Line 77  allocbuf(char *s, int maxsize) Line 76  allocbuf(char *s, int maxsize)
76                  return p;                  return p;
77          }          }
78          else          else
79                  return 0;                  return NULL;
80  }  }
81    
82  #ifndef HAVE_STRDUP  #ifndef HAVE_STRDUP
83  char *  char *
84  strdup(const char *s)  strdup(const char *s)
85  {  {
86          char *p = 0;          char *p = NULL;
87          int len;          int len;
88    
89          if (s == 0)          if (s == NULL)
90                  return 0;                  return NULL;
91    
92          len = strlen(s);          len = strlen(s);
93          p = (char *)xmalloc(len + 1);          p = (char *)xmalloc(len + 1);

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26