lt__alloc.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /* lt__alloc.h -- internal memory management interface
  2. Copyright (C) 2004, 2011-2015 Free Software Foundation, Inc.
  3. Written by Gary V. Vaughan, 2004
  4. NOTE: The canonical source of this file is maintained with the
  5. GNU Libtool package. Report bugs to bug-libtool@gnu.org.
  6. GNU Libltdl is free software; you can redistribute it and/or
  7. modify it under the terms of the GNU Lesser General Public
  8. License as published by the Free Software Foundation; either
  9. version 2 of the License, or (at your option) any later version.
  10. As a special exception to the GNU Lesser General Public License,
  11. if you distribute this file as part of a program or library that
  12. is built using GNU Libtool, you may include this file under the
  13. same distribution terms that you use for the rest of that program.
  14. GNU Libltdl is distributed in the hope that it will be useful,
  15. but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. GNU Lesser General Public License for more details.
  18. You should have received a copy of the GNU Lesser General Public
  19. License along with GNU Libltdl; see the file COPYING.LIB. If not, a
  20. copy can be downloaded from http://www.gnu.org/licenses/lgpl.html,
  21. or obtained by writing to the Free Software Foundation, Inc.,
  22. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  23. */
  24. #if !defined LT__ALLOC_H
  25. #define LT__ALLOC_H 1
  26. #include "lt_system.h"
  27. LT_BEGIN_C_DECLS
  28. #define MALLOC(tp, n) (tp*) lt__malloc((n) * sizeof(tp))
  29. #define REALLOC(tp, mem, n) (tp*) lt__realloc((mem), (n) * sizeof(tp))
  30. #define FREE(mem) LT_STMT_START { \
  31. free (mem); mem = NULL; } LT_STMT_END
  32. #define MEMREASSIGN(p, q) LT_STMT_START { \
  33. if ((p) != (q)) { free (p); (p) = (q); (q) = 0; } \
  34. } LT_STMT_END
  35. /* If set, this function is called when memory allocation has failed. */
  36. LT_SCOPE void (*lt__alloc_die) (void);
  37. LT_SCOPE void *lt__malloc (size_t n);
  38. LT_SCOPE void *lt__zalloc (size_t n);
  39. LT_SCOPE void *lt__realloc (void *mem, size_t n);
  40. LT_SCOPE void *lt__memdup (void const *mem, size_t n);
  41. LT_SCOPE char *lt__strdup (const char *string);
  42. LT_END_C_DECLS
  43. #endif /*!defined LT__ALLOC_H*/