exif-mem.h 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /*! \file exif-mem.h
  2. * \brief Define the ExifMem data type and the associated functions.
  3. * ExifMem defines the memory management functions used within libexif.
  4. */
  5. /* exif-mem.h
  6. *
  7. * Copyright (c) 2003 Lutz Mueller <lutz@users.sourceforge.net>
  8. *
  9. * This library is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU Lesser General Public
  11. * License as published by the Free Software Foundation; either
  12. * version 2 of the License, or (at your option) any later version.
  13. *
  14. * This library 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 GNU
  17. * Lesser General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Lesser General Public
  20. * License along with this library; if not, write to the
  21. * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  22. * Boston, MA 02110-1301 USA.
  23. */
  24. #ifndef LIBEXIF_EXIF_MEM_H
  25. #define LIBEXIF_EXIF_MEM_H
  26. #include <libexif/exif-utils.h>
  27. #ifdef __cplusplus
  28. extern "C" {
  29. #endif /* __cplusplus */
  30. /*! Should work like calloc()
  31. *
  32. * \param[in] s the size of the block to allocate.
  33. * \return the allocated memory and initialized.
  34. */
  35. typedef void * (* ExifMemAllocFunc) (ExifLong s);
  36. /*! Should work like realloc()
  37. *
  38. * \param[in] p the pointer to reallocate
  39. * \param[in] s the size of the reallocated block
  40. * \return allocated memory
  41. */
  42. typedef void * (* ExifMemReallocFunc) (void *p, ExifLong s);
  43. /*! Free method for ExifMem
  44. *
  45. * \param[in] p the pointer to free
  46. * \return the freed pointer
  47. */
  48. typedef void (* ExifMemFreeFunc) (void *p);
  49. /*! ExifMem define a memory allocator */
  50. typedef struct _ExifMem ExifMem;
  51. /*! Create a new ExifMem
  52. *
  53. * \param[in] a the allocator function
  54. * \param[in] r the reallocator function
  55. * \param[in] f the free function
  56. * \return allocated #ExifMem, or NULL on error
  57. */
  58. ExifMem *exif_mem_new (ExifMemAllocFunc a, ExifMemReallocFunc r,
  59. ExifMemFreeFunc f);
  60. /*! Refcount an ExifMem
  61. */
  62. void exif_mem_ref (ExifMem *);
  63. /*! Unrefcount an ExifMem.
  64. * If the refcount reaches 0, the ExifMem is freed
  65. */
  66. void exif_mem_unref (ExifMem *);
  67. void *exif_mem_alloc (ExifMem *m, ExifLong s);
  68. void *exif_mem_realloc (ExifMem *m, void *p, ExifLong s);
  69. void exif_mem_free (ExifMem *m, void *p);
  70. /*! Create a new ExifMem with default values for your convenience
  71. *
  72. * \return return a new default ExifMem
  73. */
  74. ExifMem *exif_mem_new_default (void);
  75. #ifdef __cplusplus
  76. }
  77. #endif /* __cplusplus */
  78. #endif /* !defined(LIBEXIF_EXIF_MEM_H) */