Mercurial > audlegacy
annotate Plugins/Input/wma/libffwma/mem.c @ 1540:237bb7c97759 trunk
[svn] - use posix_memalign() instead of memalign().
author | nenolod |
---|---|
date | Wed, 09 Aug 2006 02:11:01 -0700 |
parents | 57de7a460283 |
children | 9937a2512823 |
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 |
237bb7c97759
[svn] - use posix_memalign() instead of memalign().
nenolod
parents:
1399
diff
changeset
|
48 posix_memalign(&ptr, 16, size); |
237bb7c97759
[svn] - use posix_memalign() instead of memalign().
nenolod
parents:
1399
diff
changeset
|
49 |
237bb7c97759
[svn] - use posix_memalign() instead of memalign().
nenolod
parents:
1399
diff
changeset
|
50 return ptr; |
1399 | 51 } |
52 | |
53 /** | |
54 * av_realloc semantics (same as glibc): if ptr is NULL and size > 0, | |
55 * identical to malloc(size). If size is zero, it is identical to | |
56 * free(ptr) and NULL is returned. | |
57 */ | |
58 void *av_realloc(void *ptr, unsigned int size) | |
59 { | |
60 return realloc(ptr, size); | |
61 } | |
62 | |
63 /** | |
64 * Free memory which has been allocated with av_malloc(z)() or av_realloc(). | |
65 * NOTE: ptr = NULL is explicetly allowed | |
66 * Note2: it is recommended that you use av_freep() instead | |
67 */ | |
68 void av_free(void *ptr) | |
69 { | |
70 /* XXX: this test should not be needed on most libcs */ | |
71 if (ptr) | |
72 free(ptr); | |
73 } | |
74 |