2 * \brief Define the ExifMem data type and the associated functions.
3 * ExifMem defines the memory management functions used within libexif.
7 * Copyright (c) 2003 Lutz Mueller <lutz@users.sourceforge.net>
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.
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.
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.
25 #ifndef __EXIF_MEM_H__
26 #define __EXIF_MEM_H__
28 #include <libexif/exif-utils.h>
32 #endif /* __cplusplus */
34 /*! Should work like calloc()
36 * \param[in] s the size of the block to allocate.
37 * \return the allocated memory and initialized.
39 typedef void * (* ExifMemAllocFunc) (ExifLong s);
41 /*! Should work like realloc()
43 * \param[in] p the pointer to reallocate
44 * \param[in] s the size of the reallocated block
45 * \return allocated memory
47 typedef void * (* ExifMemReallocFunc) (void *p, ExifLong s);
49 /*! Free method for ExifMem
51 * \param[in] p the pointer to free
52 * \return the freed pointer
54 typedef void (* ExifMemFreeFunc) (void *p);
56 /*! ExifMem define a memory allocator */
57 typedef struct _ExifMem ExifMem;
59 /*! Create a new ExifMem
61 * \param[in] a the allocator function
62 * \param[in] r the reallocator function
63 * \param[in] f the free function
65 ExifMem *exif_mem_new (ExifMemAllocFunc a, ExifMemReallocFunc r,
67 /*! Refcount an ExifMem
69 void exif_mem_ref (ExifMem *);
71 /*! Unrefcount an ExifMem.
72 * If the refcount reaches 0, the ExifMem is freed
74 void exif_mem_unref (ExifMem *);
76 void *exif_mem_alloc (ExifMem *m, ExifLong s);
77 void *exif_mem_realloc (ExifMem *m, void *p, ExifLong s);
78 void exif_mem_free (ExifMem *m, void *p);
80 /*! Create a new ExifMem with default values for your convenience
82 * \return return a new default ExifMem
84 ExifMem *exif_mem_new_default (void);
88 #endif /* __cplusplus */
90 #endif /* __EXIF_MEM_H__ */