/src/FreeImage/Source/LibMNG/libmng_memory.h

https://bitbucket.org/cabalistic/ogredeps/ · C++ Header · 64 lines · 20 code · 8 blank · 36 comment · 9 complexity · 6fbdb4c919187dd5c6e8a5f9cbdcbcbb MD5 · raw file

  1. /* ************************************************************************** */
  2. /* * For conditions of distribution and use, * */
  3. /* * see copyright notice in libmng.h * */
  4. /* ************************************************************************** */
  5. /* * * */
  6. /* * project : libmng * */
  7. /* * file : libmng_memory.h copyright (c) 2000-2003 G.Juyn * */
  8. /* * version : 1.0.0 * */
  9. /* * * */
  10. /* * purpose : Memory management (definition) * */
  11. /* * * */
  12. /* * author : G.Juyn * */
  13. /* * * */
  14. /* * comment : Definition of memory management functions * */
  15. /* * * */
  16. /* * changes : 0.5.1 - 05/08/2000 - G.Juyn * */
  17. /* * - changed strict-ANSI stuff * */
  18. /* * * */
  19. /* * 0.5.3 - 06/12/2000 - G.Juyn * */
  20. /* * - swapped MNG_COPY parameter-names * */
  21. /* * 0.5.3 - 06/27/2000 - G.Juyn * */
  22. /* * - changed size parameter to mng_size_t * */
  23. /* * * */
  24. /* * 0.9.2 - 08/05/2000 - G.Juyn * */
  25. /* * - changed file-prefixes * */
  26. /* * * */
  27. /* ************************************************************************** */
  28. #if defined(__BORLANDC__) && defined(MNG_STRICT_ANSI)
  29. #pragma option -A /* force ANSI-C */
  30. #endif
  31. #ifndef _libmng_memory_h_
  32. #define _libmng_memory_h_
  33. /* ************************************************************************** */
  34. /* * * */
  35. /* * Generic memory manager macros * */
  36. /* * * */
  37. /* ************************************************************************** */
  38. #ifdef MNG_INTERNAL_MEMMNGMT
  39. #define MNG_ALLOC(H,P,L) { P = calloc (1, (mng_size_t)(L)); \
  40. if (P == 0) { MNG_ERROR (H, MNG_OUTOFMEMORY) } }
  41. #define MNG_ALLOCX(H,P,L) { P = calloc (1, (mng_size_t)(L)); }
  42. #define MNG_FREE(H,P,L) { if (P) { free (P); P = 0; } }
  43. #define MNG_FREEX(H,P,L) { if (P) free (P); }
  44. #else
  45. #define MNG_ALLOC(H,P,L) { P = H->fMemalloc ((mng_size_t)(L)); \
  46. if (P == 0) { MNG_ERROR (H, MNG_OUTOFMEMORY) } }
  47. #define MNG_ALLOCX(H,P,L) { P = H->fMemalloc ((mng_size_t)(L)); }
  48. #define MNG_FREE(H,P,L) { if (P) { H->fMemfree (P, (mng_size_t)(L)); P = 0; } }
  49. #define MNG_FREEX(H,P,L) { if (P) { H->fMemfree (P, (mng_size_t)(L)); } }
  50. #endif /* mng_internal_memmngmt */
  51. #define MNG_COPY(D,S,L) { memcpy (D, S, (mng_size_t)(L)); }
  52. /* ************************************************************************** */
  53. #endif /* _libmng_memory_h_ */
  54. /* ************************************************************************** */
  55. /* * end of file * */
  56. /* ************************************************************************** */