[BACK]Return to xmalloc.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / ssh

Diff for /src/usr.bin/ssh/xmalloc.c between version 1.11 and 1.12

version 1.11, 2001/02/04 15:32:27 version 1.12, 2001/02/07 08:57:26
Line 21 
Line 21 
 void *  void *
 xmalloc(size_t size)  xmalloc(size_t size)
 {  {
         void *ptr = malloc(size);          void *ptr;
   
           if (size == 0)
                   fatal("xmalloc: zero size");
           ptr = malloc(size);
         if (ptr == NULL)          if (ptr == NULL)
                 fatal("xmalloc: out of memory (allocating %d bytes)", (int) size);                  fatal("xmalloc: out of memory (allocating %d bytes)", (int) size);
         return ptr;          return ptr;
Line 32 
Line 36 
 {  {
         void *new_ptr;          void *new_ptr;
   
           if (new_size == 0)
                   fatal("xmalloc: zero size");
         if (ptr == NULL)          if (ptr == NULL)
                 fatal("xrealloc: NULL pointer given as argument");                  fatal("xrealloc: NULL pointer given as argument");
         new_ptr = realloc(ptr, new_size);          new_ptr = realloc(ptr, new_size);
Line 52 
Line 58 
 xstrdup(const char *str)  xstrdup(const char *str)
 {  {
         size_t len = strlen(str) + 1;          size_t len = strlen(str) + 1;
           char *cp;
   
         char *cp = xmalloc(len);          if (len == 0)
                   fatal("xmalloc: zero size");
           cp = xmalloc(len);
         strlcpy(cp, str, len);          strlcpy(cp, str, len);
         return cp;          return cp;
 }  }

Legend:
Removed from v.1.11  
changed lines
  Added in v.1.12