1 ///////////////////////////////////////////////////////////////////////////////
4 /// \brief Memory allocation functions
6 // Copyright (C) 2007 Lasse Collin
8 // This program is free software; you can redistribute it and/or
9 // modify it under the terms of the GNU Lesser General Public
10 // License as published by the Free Software Foundation; either
11 // version 2.1 of the License, or (at your option) any later version.
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 // Lesser General Public License for more details.
18 ///////////////////////////////////////////////////////////////////////////////
26 /// Safe malloc() that never returns NULL.
27 extern void *xmalloc(size_t size);
29 /// Safe realloc() that never returns NULL.
30 extern void *xrealloc(void *ptr, size_t size);
32 /// Safe strdup() that never returns NULL.
33 extern char *xstrdup(const char *src);
35 /// xrealloc()s *dest to the size needed by src, and copies src to *dest.
36 extern void xstrcpy(char **dest, const char *src);
38 /// Function for lzma_allocator.alloc. This uses xmalloc().
39 extern void *allocator(void *opaque lzma_attribute((unused)),
40 size_t nmemb lzma_attribute((unused)), size_t size);