/* --------------------------------------------------------------------------- * catches signals which abort the program */ void CatchSignal (int Signal) { char *s; switch (Signal) { #ifdef SIGHUP case SIGHUP: s = "SIGHUP"; break; #endif case SIGINT: s = "SIGINT"; break; #ifdef SIGQUIT case SIGQUIT: s = "SIGQUIT"; break; #endif case SIGABRT: s = "SIGABRT"; break; case SIGTERM: s = "SIGTERM"; break; case SIGSEGV: s = "SIGSEGV"; break; default: s = "unknown"; break; } MyFatal ("aborted by %s signal\n", s); }
void CatchSignal( int Signal ) { int eax; char *s; s[0] = "unknown"; MyFatal( "aborted by %s signal\n", s ); return; }
/* --------------------------------------------------------------------------- * allocates memory for a new string, does some error processing */ char * MyStrdup (char *S, const char *Text) { char *p = NULL; /* bug-fix by Ulrich Pegelow ([email protected]) */ if (S && ((p = strdup (S)) == NULL)) MyFatal ("out of memory during g_strdup() in '%s'\n", (Text ? Text : "(unknown)")); #ifdef MEM_DEBUG fprintf (stderr, "g_strdup returning 0x%x\n", p); #endif return (p); }
/* --------------------------------------------------------------------------- * allocates memory with error handling * this is a save version because BSD doesn't support the * handling of NULL pointers in realloc() */ void * MyRealloc (void *Ptr, size_t Size, const char *Text) { void *p; #ifdef MEM_DEBUG fprintf (stderr, "0x%x Realloc to %d from %s ", Ptr, Size, Text); #endif if (Size == 0) Size = 1; p = Ptr ? realloc (Ptr, Size) : malloc (Size); if (!p) MyFatal ("out of memory during realloc() in '%s'()\n", (Text ? Text : "(unknown)")); #ifdef MEM_DEBUG fprintf (stderr, "returned 0x%x\n", p); #endif return (p); }
void * MyMalloc (size_t Size, const char *Text) { void *p; #ifdef MEM_DEBUG fprintf (stderr, "MyMalloc %d by %d from %s ", Number, Size, Text); #endif /* avoid malloc of 0 bytes */ if (Size == 0) Size = 1; if ((p = malloc (Size)) == NULL) MyFatal ("out of memory during malloc() in '%s'()\n", (Text ? Text : "(unknown)")); #ifdef MEM_DEBUG fprintf (stderr, "returned 0x%x\n", p); #endif return (p); }
/* --------------------------------------------------------------------------- * allocates memory with error handling */ void * MyCalloc (size_t Number, size_t Size, const char *Text) { void *p; #ifdef MEM_DEBUG fprintf (stderr, "MyCalloc %d by %d from %s ", Number, Size, Text); #endif /* InitComponentLookup() at least can ask for zero here, so return something | that can be freed. */ if (Number == 0) Number = 1; if (Size == 0) Size = 1; if ((p = calloc (Number, Size)) == NULL) MyFatal ("out of memory during malloc() in '%s'()\n", (Text ? Text : "(unknown)")); #ifdef MEM_DEBUG fprintf (stderr, "returned 0x%x\n", p); #endif return (p); }