bluray: factorize blurayReleaseVout()
[vlc.git] / include / vlc_memory.h
blob22ea0ea385ff1c940809b4b9a64f53acf8e2025e
1 /*****************************************************************************
2 * vlc_memory.h: Memory functions
3 *****************************************************************************
4 * Copyright (C) 2009 VLC authors and VideoLAN
6 * Authors: JP Dinger <jpd at videolan dot org>
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU Lesser General Public License as published by
10 * the Free Software Foundation; either version 2.1 of the License, or
11 * (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
16 * GNU Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public License
19 * along with this program; if not, write to the Free Software Foundation,
20 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
21 *****************************************************************************/
23 #ifndef VLC_MEMORY_H
24 #define VLC_MEMORY_H 1
26 #include <stdlib.h>
28 /**
29 * \defgroup memory Memory
30 * @{
31 * \file
32 * Memory fixups
35 /**
36 * This wrapper around realloc() will free the input pointer when
37 * realloc() returns NULL. The use case ptr = realloc(ptr, newsize) will
38 * cause a memory leak when ptr pointed to a heap allocation before,
39 * leaving the buffer allocated but unreferenced. vlc_realloc() is a
40 * drop-in replacement for that use case (and only that use case).
42 static inline void *realloc_or_free( void *p, size_t sz )
44 void *n = realloc(p,sz);
45 if( !n )
46 free(p);
47 return n;
50 /**
51 * @}
54 #endif