X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=include%2Flibfirm%2Fadt%2Fxmalloc.h;h=a4cfaa7bd1ba482c35186b5494b4221b2088fca9;hb=97bcf6f245eba55a1d3b25a7be543b367ab9c276;hp=85a45a302352ec82e612c5e04e350236c23e89ce;hpb=1a3b7d363474ab544c13093a2f0b578718d37c7a;p=libfirm diff --git a/include/libfirm/adt/xmalloc.h b/include/libfirm/adt/xmalloc.h index 85a45a302..a4cfaa7bd 100644 --- a/include/libfirm/adt/xmalloc.h +++ b/include/libfirm/adt/xmalloc.h @@ -21,7 +21,6 @@ * @file * @brief never failing wrappers for malloc() & friends. * @author Markus Armbruster - * @version $Id$ * @note The functions here never fail because they simply abort your * program in case of an error. */ @@ -36,18 +35,40 @@ #ifdef _WIN32 #include #endif -#ifdef HAVE_ALLOCA_H +#if defined(__linux__) || defined(__APPLE__) #include #endif #include "../begin.h" -/* xmalloc() & friends. */ +/** + * @ingroup adt + * @defgroup xmalloc Memory Allocation + * @{ + */ +/** + * Allocate @p size bytes on the heap. + * This is a wrapper for malloc which calls panic() in case of errors, so no + * error handling is required for code using it. + */ FIRM_API void *xmalloc(size_t size); +/** + * Chane size of a previously allocated memory block to @p size bytes. + * This is a wrapper for realloc which calls panic() in case of errors, so no + * error handling is required for code using it. + */ FIRM_API void *xrealloc(void *ptr, size_t size); +/** + * Allocates memory and copies string @p str into it. + * This is a wrapper for strdup which calls panic() in case of errors, so no + * error handling is required for code using it. + */ FIRM_API char *xstrdup(const char *str); - +/** + * Another name for the free function + * @deprecated + */ #define xfree(ptr) free(ptr) /** @@ -128,6 +149,7 @@ FIRM_API char *xstrdup(const char *str); */ #define OALLOCFZ(obst, type, member, n) ((type*)memset(OALLOCF((obst), type, member, (n)), 0, offsetof(type, member) + sizeof(*((type*)0)->member) * (n))) +/** @} */ #include "../end.h"