Mercurial > audlegacy
annotate Plugins/Input/wma/libffwma/mem.c @ 1715:14e6dd38e108 trunk
[svn] Fixed 3 warnings, 2 unused variables and 1 missing include
author | js |
---|---|
date | Sat, 16 Sep 2006 10:08:23 -0700 |
parents | de0a0927a5c2 |
children |
rev | line source |
---|---|
1399 | 1 /* |
2 * default memory allocator for libavcodec | |
3 * Copyright (c) 2002 Fabrice Bellard. | |
4 * | |
5 * This library is free software; you can redistribute it and/or | |
6 * modify it under the terms of the GNU Lesser General Public | |
7 * License as published by the Free Software Foundation; either | |
8 * version 2 of the License, or (at your option) any later version. | |
9 * | |
10 * This library is distributed in the hope that it will be useful, | |
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 * Lesser General Public License for more details. | |
14 * | |
15 * You should have received a copy of the GNU Lesser General Public | |
16 * License along with this library; if not, write to the Free Software | |
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | |
18 */ | |
19 | |
20 /** | |
21 * @file mem.c | |
22 * default memory allocator for libavcodec. | |
23 */ | |
24 | |
25 #include "avcodec.h" | |
26 | |
27 /* here we can use OS dependant allocation functions */ | |
28 #undef malloc | |
29 #undef free | |
30 #undef realloc | |
31 | |
1540
237bb7c97759
[svn] - use posix_memalign() instead of memalign().
nenolod
parents:
1399
diff
changeset
|
32 #define _XOPEN_SOURCE 600 |
237bb7c97759
[svn] - use posix_memalign() instead of memalign().
nenolod
parents:
1399
diff
changeset
|
33 #include <stdlib.h> |
1399 | 34 |
35 /* you can redefine av_malloc and av_free in your project to use your | |
36 memory allocator. You do not need to suppress this file because the | |
37 linker will do it automatically */ | |
38 | |
39 /** | |
40 * Memory allocation of size byte with alignment suitable for all | |
41 * memory accesses (including vectors if available on the | |
42 * CPU). av_malloc(0) must return a non NULL pointer. | |
43 */ | |
44 void *av_malloc(unsigned int size) | |
45 { | |
1540
237bb7c97759
[svn] - use posix_memalign() instead of memalign().
nenolod
parents:
1399
diff
changeset
|
46 void *ptr; |
237bb7c97759
[svn] - use posix_memalign() instead of memalign().
nenolod
parents:
1399
diff
changeset
|
47 |
1665
de0a0927a5c2
[svn] Revert broken commit r2209 and fseek -> vfs_fseek, missed in commit r2265.
chainsaw
parents:
1639
diff
changeset
|
48 #ifdef __GLIBC__ |
1540
237bb7c97759
[svn] - use posix_memalign() instead of memalign().
nenolod
parents:
1399
diff
changeset
|
49 posix_memalign(&ptr, 16, size); |
1638
9937a2512823
[svn] - wma.c: use av_malloc() instead of directly using posix_memalign()
nenolod
parents:
1540
diff
changeset
|
50 #else |
9937a2512823
[svn] - wma.c: use av_malloc() instead of directly using posix_memalign()
nenolod
parents:
1540
diff
changeset
|
51 ptr = malloc(size); |
9937a2512823
[svn] - wma.c: use av_malloc() instead of directly using posix_memalign()
nenolod
parents:
1540
diff
changeset
|
52 #endif |
1540
237bb7c97759
[svn] - use posix_memalign() instead of memalign().
nenolod
parents:
1399
diff
changeset
|
53 |
237bb7c97759
[svn] - use posix_memalign() instead of memalign().
nenolod
parents:
1399
diff
changeset
|
54 return ptr; |
1399 | 55 } |
56 | |
57 /** | |
58 * av_realloc semantics (same as glibc): if ptr is NULL and size > 0, | |
59 * identical to malloc(size). If size is zero, it is identical to | |
60 * free(ptr) and NULL is returned. | |
61 */ | |
62 void *av_realloc(void *ptr, unsigned int size) | |
63 { | |
64 return realloc(ptr, size); | |
65 } | |
66 | |
67 /** | |
68 * Free memory which has been allocated with av_malloc(z)() or av_realloc(). | |
69 * NOTE: ptr = NULL is explicetly allowed | |
70 * Note2: it is recommended that you use av_freep() instead | |
71 */ | |
72 void av_free(void *ptr) | |
73 { | |
74 /* XXX: this test should not be needed on most libcs */ | |
75 if (ptr) | |
76 free(ptr); | |
77 } | |
78 |