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