exif-mem.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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 __EXIF_MEM_H__
  25. #define __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. */
  57. ExifMem *exif_mem_new (ExifMemAllocFunc a, ExifMemReallocFunc r,
  58. ExifMemFreeFunc f);
  59. /*! Refcount an ExifMem
  60. */
  61. void exif_mem_ref (ExifMem *);
  62. /*! Unrefcount an ExifMem.
  63. * If the refcount reaches 0, the ExifMem is freed
  64. */
  65. void exif_mem_unref (ExifMem *);
  66. void *exif_mem_alloc (ExifMem *m, ExifLong s);
  67. void *exif_mem_realloc (ExifMem *m, void *p, ExifLong s);
  68. void exif_mem_free (ExifMem *m, void *p);
  69. /*! Create a new ExifMem with default values for your convenience
  70. *
  71. * \return return a new default ExifMem
  72. */
  73. ExifMem *exif_mem_new_default (void);
  74. #ifdef __cplusplus
  75. }
  76. #endif /* __cplusplus */
  77. #endif /* __EXIF_MEM_H__ */