home *** CD-ROM | disk | FTP | other *** search
/ Dream 52 / Amiga_Dream_52.iso / Linux / Enlightenment / enl14.tgz / enl14.tar / enl14 / misc.c < prev    next >
C/C++ Source or Header  |  1997-11-06  |  923b  |  65 lines

  1. #include "enl.h"
  2.  
  3. void EExit(int code)
  4. {
  5.    char s[1024];
  6.    
  7.    if ((ThemeDir)&&(ThemeIsTmp))
  8.      {
  9.     sprintf(s,"/bin/rm -rf %s",ThemeDir);
  10.     system(s);
  11.      }
  12.    exit(code);
  13. }
  14.  
  15. void *Emalloc(int size)
  16. {
  17.    void *p;
  18.    
  19.    p=NULL;
  20.    if (size<=0) 
  21.      {
  22.     Alert("Warning! Attempt to malloc 0 bytes\n");
  23.     return NULL;
  24.      }
  25.    else
  26.      {
  27.     p=malloc(size);
  28.     if (!p) Alert("Warning! malloc for %i bytes failed\n",size);
  29.     return p;
  30.      }
  31. }
  32.  
  33. void *Erealloc(void *ptr, int size)
  34. {
  35.    void *p;
  36.    
  37.    p=NULL;
  38.    if (size<=0) 
  39.      {
  40.     Alert("Warning! Attempt to realloc 0 bytes\n");
  41.     Efree(ptr);
  42.     return NULL;
  43.      }
  44.    else if (ptr==NULL)
  45.      {
  46.     return Emalloc(size);
  47.      }
  48.    else
  49.      {
  50.     p=realloc(ptr,size);
  51.     if (!p) Alert("Warning! realloc for %i bytes failed\n",size);
  52.     return p;
  53.      }
  54. }
  55.  
  56. void Efree(void *ptr)
  57. {
  58.    if (!ptr)
  59.      Alert("Warning! Attempting to free NULL pointer\n");
  60.    else
  61.      {
  62.     free(ptr);
  63.      }
  64. }
  65.