#include #include #include #include #include #include #include "G3d_intern.h" /*---------------------------------------------------------------------------*/ /*! * \brief * * Same as malloc (nBytes), except that in case of error * G3d_error() is invoked. * * \param nBytes * \return void *: a pointer ... if successful, * NULL ... otherwise. */ void * G3d_malloc (int nBytes) { char *buf; if (nBytes <= 0) nBytes = 1; if ((buf = malloc (nBytes)) != NULL) return buf; G3d_error ("G3d_malloc: out of memory"); return (void *) NULL; } /*! * \brief * * Same as realloc (ptr, nBytes), except that in case of error * G3d_error() is invoked. * * \param ptr * \param nBytes * \return void *: a pointer ... if successful, * NULL ... otherwise. */ void * G3d_realloc (void *ptr, int nBytes) { if (nBytes <= 0) nBytes = 1; if ((ptr = realloc (ptr, nBytes)) != NULL) return ptr; G3d_error ("G3d_realloc: out of memory"); return (void *) NULL; } /*! * \brief * * Same as free (ptr). * * \param ptr * \return void */ void G3d_free (void *buf) { free (buf); }