Mercurial > libavutil.hg
annotate mem.h @ 878:1380f7caffd6 libavutil
Add missing parentheses around the AVERROR_PATCHWELCOME macro
definition.
author | stefano |
---|---|
date | Sat, 13 Mar 2010 09:52:43 +0000 |
parents | 4d9ad0ed07d0 |
children | 0795a743bda1 |
rev | line source |
---|---|
108
11be8e0d1344
Add official LGPL license headers to the files that were missing them.
diego
parents:
104
diff
changeset
|
1 /* |
11be8e0d1344
Add official LGPL license headers to the files that were missing them.
diego
parents:
104
diff
changeset
|
2 * copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at> |
11be8e0d1344
Add official LGPL license headers to the files that were missing them.
diego
parents:
104
diff
changeset
|
3 * |
116
d76a36742464
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
113
diff
changeset
|
4 * This file is part of FFmpeg. |
d76a36742464
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
113
diff
changeset
|
5 * |
d76a36742464
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
113
diff
changeset
|
6 * FFmpeg is free software; you can redistribute it and/or |
108
11be8e0d1344
Add official LGPL license headers to the files that were missing them.
diego
parents:
104
diff
changeset
|
7 * modify it under the terms of the GNU Lesser General Public |
11be8e0d1344
Add official LGPL license headers to the files that were missing them.
diego
parents:
104
diff
changeset
|
8 * License as published by the Free Software Foundation; either |
116
d76a36742464
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
113
diff
changeset
|
9 * version 2.1 of the License, or (at your option) any later version. |
108
11be8e0d1344
Add official LGPL license headers to the files that were missing them.
diego
parents:
104
diff
changeset
|
10 * |
116
d76a36742464
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
113
diff
changeset
|
11 * FFmpeg is distributed in the hope that it will be useful, |
108
11be8e0d1344
Add official LGPL license headers to the files that were missing them.
diego
parents:
104
diff
changeset
|
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
11be8e0d1344
Add official LGPL license headers to the files that were missing them.
diego
parents:
104
diff
changeset
|
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
11be8e0d1344
Add official LGPL license headers to the files that were missing them.
diego
parents:
104
diff
changeset
|
14 * Lesser General Public License for more details. |
11be8e0d1344
Add official LGPL license headers to the files that were missing them.
diego
parents:
104
diff
changeset
|
15 * |
11be8e0d1344
Add official LGPL license headers to the files that were missing them.
diego
parents:
104
diff
changeset
|
16 * You should have received a copy of the GNU Lesser General Public |
116
d76a36742464
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
113
diff
changeset
|
17 * License along with FFmpeg; if not, write to the Free Software |
108
11be8e0d1344
Add official LGPL license headers to the files that were missing them.
diego
parents:
104
diff
changeset
|
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
11be8e0d1344
Add official LGPL license headers to the files that were missing them.
diego
parents:
104
diff
changeset
|
19 */ |
11be8e0d1344
Add official LGPL license headers to the files that were missing them.
diego
parents:
104
diff
changeset
|
20 |
0
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
21 /** |
642
70bdd5501662
Use full internal pathname in doxygen @file directives.
diego
parents:
633
diff
changeset
|
22 * @file libavutil/mem.h |
633 | 23 * memory handling functions |
0
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
24 */ |
ee8f44bb7c4d
libavutil: Utility code from libavcodec moved to a separate library.
al
parents:
diff
changeset
|
25 |
567 | 26 #ifndef AVUTIL_MEM_H |
27 #define AVUTIL_MEM_H | |
104
5111e87117b7
Align the input buffer in ffplay, introduce a public macro for aligned declarations
lu_zero
parents:
100
diff
changeset
|
28 |
873
4d9ad0ed07d0
Replace many includes of libavutil/common.h with what is actually needed
mru
parents:
859
diff
changeset
|
29 #include "attributes.h" |
590
e9d89a89561a
Use AV_GCC_VERSION_AT_LEAST() to simplify gcc version checks.
cehoyos
parents:
574
diff
changeset
|
30 |
746
3b90ae5577ad
Move DECLARE_ALIGNED and DECLARE_ASM_CONST back from lavu/internal.h to
ramiro
parents:
742
diff
changeset
|
31 #if defined(__ICC) || defined(__SUNPRO_C) |
819
1672d4566595
Make DECLARE_ALIGNED macros work with external array specifiers
mru
parents:
804
diff
changeset
|
32 #define DECLARE_ALIGNED(n,t,v) t __attribute__ ((aligned (n))) v |
746
3b90ae5577ad
Move DECLARE_ALIGNED and DECLARE_ASM_CONST back from lavu/internal.h to
ramiro
parents:
742
diff
changeset
|
33 #define DECLARE_ASM_CONST(n,t,v) const t __attribute__ ((aligned (n))) v |
822 | 34 #elif defined(__TI_COMPILER_VERSION__) |
35 #define DECLARE_ALIGNED(n,t,v) \ | |
36 AV_PRAGMA(DATA_ALIGN(v,n)) \ | |
37 t __attribute__((aligned(n))) v | |
38 #define DECLARE_ASM_CONST(n,t,v) \ | |
39 AV_PRAGMA(DATA_ALIGN(v,n)) \ | |
40 static const t __attribute__((aligned(n))) v | |
746
3b90ae5577ad
Move DECLARE_ALIGNED and DECLARE_ASM_CONST back from lavu/internal.h to
ramiro
parents:
742
diff
changeset
|
41 #elif defined(__GNUC__) |
819
1672d4566595
Make DECLARE_ALIGNED macros work with external array specifiers
mru
parents:
804
diff
changeset
|
42 #define DECLARE_ALIGNED(n,t,v) t __attribute__ ((aligned (n))) v |
1672d4566595
Make DECLARE_ALIGNED macros work with external array specifiers
mru
parents:
804
diff
changeset
|
43 #define DECLARE_ASM_CONST(n,t,v) static const t attribute_used __attribute__ ((aligned (n))) v |
746
3b90ae5577ad
Move DECLARE_ALIGNED and DECLARE_ASM_CONST back from lavu/internal.h to
ramiro
parents:
742
diff
changeset
|
44 #elif defined(_MSC_VER) |
3b90ae5577ad
Move DECLARE_ALIGNED and DECLARE_ASM_CONST back from lavu/internal.h to
ramiro
parents:
742
diff
changeset
|
45 #define DECLARE_ALIGNED(n,t,v) __declspec(align(n)) t v |
3b90ae5577ad
Move DECLARE_ALIGNED and DECLARE_ASM_CONST back from lavu/internal.h to
ramiro
parents:
742
diff
changeset
|
46 #define DECLARE_ASM_CONST(n,t,v) __declspec(align(n)) static const t v |
3b90ae5577ad
Move DECLARE_ALIGNED and DECLARE_ASM_CONST back from lavu/internal.h to
ramiro
parents:
742
diff
changeset
|
47 #else |
3b90ae5577ad
Move DECLARE_ALIGNED and DECLARE_ASM_CONST back from lavu/internal.h to
ramiro
parents:
742
diff
changeset
|
48 #define DECLARE_ALIGNED(n,t,v) t v |
3b90ae5577ad
Move DECLARE_ALIGNED and DECLARE_ASM_CONST back from lavu/internal.h to
ramiro
parents:
742
diff
changeset
|
49 #define DECLARE_ASM_CONST(n,t,v) static const t v |
3b90ae5577ad
Move DECLARE_ALIGNED and DECLARE_ASM_CONST back from lavu/internal.h to
ramiro
parents:
742
diff
changeset
|
50 #endif |
3b90ae5577ad
Move DECLARE_ALIGNED and DECLARE_ASM_CONST back from lavu/internal.h to
ramiro
parents:
742
diff
changeset
|
51 |
590
e9d89a89561a
Use AV_GCC_VERSION_AT_LEAST() to simplify gcc version checks.
cehoyos
parents:
574
diff
changeset
|
52 #if AV_GCC_VERSION_AT_LEAST(3,1) |
481
f4187c1c15a6
Reapply r12489: Add pure, const and malloc attributes to proper functions
zuxy
parents:
478
diff
changeset
|
53 #define av_malloc_attrib __attribute__((__malloc__)) |
f4187c1c15a6
Reapply r12489: Add pure, const and malloc attributes to proper functions
zuxy
parents:
478
diff
changeset
|
54 #else |
f4187c1c15a6
Reapply r12489: Add pure, const and malloc attributes to proper functions
zuxy
parents:
478
diff
changeset
|
55 #define av_malloc_attrib |
f4187c1c15a6
Reapply r12489: Add pure, const and malloc attributes to proper functions
zuxy
parents:
478
diff
changeset
|
56 #endif |
f4187c1c15a6
Reapply r12489: Add pure, const and malloc attributes to proper functions
zuxy
parents:
478
diff
changeset
|
57 |
742
1091b120412e
Icc 11.1 does not support attributes force_align_arg_pointer, alloc_size and cold.
cehoyos
parents:
738
diff
changeset
|
58 #if (!defined(__ICC) || __ICC > 1110) && AV_GCC_VERSION_AT_LEAST(4,3) |
482
0b8d0ec536a8
Apply "alloc_size" attribute to av_alloc, av_realloc and av_mallocz
zuxy
parents:
481
diff
changeset
|
59 #define av_alloc_size(n) __attribute__((alloc_size(n))) |
0b8d0ec536a8
Apply "alloc_size" attribute to av_alloc, av_realloc and av_mallocz
zuxy
parents:
481
diff
changeset
|
60 #else |
0b8d0ec536a8
Apply "alloc_size" attribute to av_alloc, av_realloc and av_mallocz
zuxy
parents:
481
diff
changeset
|
61 #define av_alloc_size(n) |
0b8d0ec536a8
Apply "alloc_size" attribute to av_alloc, av_realloc and av_mallocz
zuxy
parents:
481
diff
changeset
|
62 #endif |
0b8d0ec536a8
Apply "alloc_size" attribute to av_alloc, av_realloc and av_mallocz
zuxy
parents:
481
diff
changeset
|
63 |
278
ca3eb39d3aa2
Move unaltered av_malloc() comments to the header file.
takis
parents:
252
diff
changeset
|
64 /** |
738
4f98a323598c
Remove '\p', '\c' and '\e' doxygen markup from doxy, as it should
stefano
parents:
642
diff
changeset
|
65 * Allocates a block of size bytes with alignment suitable for all |
399
ae3fbcfbad4c
Doxyfication, patch by Stefano Sabatini %stefano P sabatini-lala A poste P it%
gpoirier
parents:
398
diff
changeset
|
66 * memory accesses (including vectors if available on the CPU). |
ae3fbcfbad4c
Doxyfication, patch by Stefano Sabatini %stefano P sabatini-lala A poste P it%
gpoirier
parents:
398
diff
changeset
|
67 * @param size Size in bytes for the memory block to be allocated. |
633 | 68 * @return Pointer to the allocated block, NULL if the block cannot |
69 * be allocated. | |
399
ae3fbcfbad4c
Doxyfication, patch by Stefano Sabatini %stefano P sabatini-lala A poste P it%
gpoirier
parents:
398
diff
changeset
|
70 * @see av_mallocz() |
278
ca3eb39d3aa2
Move unaltered av_malloc() comments to the header file.
takis
parents:
252
diff
changeset
|
71 */ |
482
0b8d0ec536a8
Apply "alloc_size" attribute to av_alloc, av_realloc and av_mallocz
zuxy
parents:
481
diff
changeset
|
72 void *av_malloc(unsigned int size) av_malloc_attrib av_alloc_size(1); |
279
4964532166e6
Move unaltered av_realloc() comments to the header file.
takis
parents:
278
diff
changeset
|
73 |
4964532166e6
Move unaltered av_realloc() comments to the header file.
takis
parents:
278
diff
changeset
|
74 /** |
633 | 75 * Allocates or reallocates a block of memory. |
804
3184397c9fdb
Remove residual use of the doxygen markup which is deprecated,
stefano
parents:
746
diff
changeset
|
76 * If ptr is NULL and size > 0, allocates a new block. If |
738
4f98a323598c
Remove '\p', '\c' and '\e' doxygen markup from doxy, as it should
stefano
parents:
642
diff
changeset
|
77 * size is zero, frees the memory block pointed to by ptr. |
399
ae3fbcfbad4c
Doxyfication, patch by Stefano Sabatini %stefano P sabatini-lala A poste P it%
gpoirier
parents:
398
diff
changeset
|
78 * @param size Size in bytes for the memory block to be allocated or |
ae3fbcfbad4c
Doxyfication, patch by Stefano Sabatini %stefano P sabatini-lala A poste P it%
gpoirier
parents:
398
diff
changeset
|
79 * reallocated. |
ae3fbcfbad4c
Doxyfication, patch by Stefano Sabatini %stefano P sabatini-lala A poste P it%
gpoirier
parents:
398
diff
changeset
|
80 * @param ptr Pointer to a memory block already allocated with |
ae3fbcfbad4c
Doxyfication, patch by Stefano Sabatini %stefano P sabatini-lala A poste P it%
gpoirier
parents:
398
diff
changeset
|
81 * av_malloc(z)() or av_realloc() or NULL. |
633 | 82 * @return Pointer to a newly reallocated block or NULL if the block |
83 * cannot be reallocated or the function is used to free the memory block. | |
399
ae3fbcfbad4c
Doxyfication, patch by Stefano Sabatini %stefano P sabatini-lala A poste P it%
gpoirier
parents:
398
diff
changeset
|
84 * @see av_fast_realloc() |
279
4964532166e6
Move unaltered av_realloc() comments to the header file.
takis
parents:
278
diff
changeset
|
85 */ |
482
0b8d0ec536a8
Apply "alloc_size" attribute to av_alloc, av_realloc and av_mallocz
zuxy
parents:
481
diff
changeset
|
86 void *av_realloc(void *ptr, unsigned int size) av_alloc_size(2); |
280
8c22d0665daa
Move unaltered av_free() comments to the header file.
takis
parents:
279
diff
changeset
|
87 |
8c22d0665daa
Move unaltered av_free() comments to the header file.
takis
parents:
279
diff
changeset
|
88 /** |
633 | 89 * Frees a memory block which has been allocated with av_malloc(z)() or |
399
ae3fbcfbad4c
Doxyfication, patch by Stefano Sabatini %stefano P sabatini-lala A poste P it%
gpoirier
parents:
398
diff
changeset
|
90 * av_realloc(). |
ae3fbcfbad4c
Doxyfication, patch by Stefano Sabatini %stefano P sabatini-lala A poste P it%
gpoirier
parents:
398
diff
changeset
|
91 * @param ptr Pointer to the memory block which should be freed. |
398
d525bf15ea54
doxy/cosmetics fixes. Patch by Stefano Sabatini %stefano P sabatini-lala A posteP it %
gpoirier
parents:
392
diff
changeset
|
92 * @note ptr = NULL is explicitly allowed. |
d525bf15ea54
doxy/cosmetics fixes. Patch by Stefano Sabatini %stefano P sabatini-lala A posteP it %
gpoirier
parents:
392
diff
changeset
|
93 * @note It is recommended that you use av_freep() instead. |
399
ae3fbcfbad4c
Doxyfication, patch by Stefano Sabatini %stefano P sabatini-lala A poste P it%
gpoirier
parents:
398
diff
changeset
|
94 * @see av_freep() |
280
8c22d0665daa
Move unaltered av_free() comments to the header file.
takis
parents:
279
diff
changeset
|
95 */ |
82
8fb151c4d4c7
Move av_malloc(), av_realloc(), and av_free() from libavcodec to libavutil
lucabe
parents:
80
diff
changeset
|
96 void av_free(void *ptr); |
8fb151c4d4c7
Move av_malloc(), av_realloc(), and av_free() from libavcodec to libavutil
lucabe
parents:
80
diff
changeset
|
97 |
399
ae3fbcfbad4c
Doxyfication, patch by Stefano Sabatini %stefano P sabatini-lala A poste P it%
gpoirier
parents:
398
diff
changeset
|
98 /** |
738
4f98a323598c
Remove '\p', '\c' and '\e' doxygen markup from doxy, as it should
stefano
parents:
642
diff
changeset
|
99 * Allocates a block of size bytes with alignment suitable for all |
399
ae3fbcfbad4c
Doxyfication, patch by Stefano Sabatini %stefano P sabatini-lala A poste P it%
gpoirier
parents:
398
diff
changeset
|
100 * memory accesses (including vectors if available on the CPU) and |
633 | 101 * zeroes all the bytes of the block. |
399
ae3fbcfbad4c
Doxyfication, patch by Stefano Sabatini %stefano P sabatini-lala A poste P it%
gpoirier
parents:
398
diff
changeset
|
102 * @param size Size in bytes for the memory block to be allocated. |
633 | 103 * @return Pointer to the allocated block, NULL if it cannot be allocated. |
399
ae3fbcfbad4c
Doxyfication, patch by Stefano Sabatini %stefano P sabatini-lala A poste P it%
gpoirier
parents:
398
diff
changeset
|
104 * @see av_malloc() |
ae3fbcfbad4c
Doxyfication, patch by Stefano Sabatini %stefano P sabatini-lala A poste P it%
gpoirier
parents:
398
diff
changeset
|
105 */ |
482
0b8d0ec536a8
Apply "alloc_size" attribute to av_alloc, av_realloc and av_mallocz
zuxy
parents:
481
diff
changeset
|
106 void *av_mallocz(unsigned int size) av_malloc_attrib av_alloc_size(1); |
382 | 107 |
108 /** | |
738
4f98a323598c
Remove '\p', '\c' and '\e' doxygen markup from doxy, as it should
stefano
parents:
642
diff
changeset
|
109 * Duplicates the string s. |
633 | 110 * @param s string to be duplicated |
382 | 111 * @return Pointer to a newly allocated string containing a |
738
4f98a323598c
Remove '\p', '\c' and '\e' doxygen markup from doxy, as it should
stefano
parents:
642
diff
changeset
|
112 * copy of s or NULL if the string cannot be allocated. |
382 | 113 */ |
481
f4187c1c15a6
Reapply r12489: Add pure, const and malloc attributes to proper functions
zuxy
parents:
478
diff
changeset
|
114 char *av_strdup(const char *s) av_malloc_attrib; |
281
411c8cbd578a
Move unaltered av_freep() comments to the header file.
takis
parents:
280
diff
changeset
|
115 |
411c8cbd578a
Move unaltered av_freep() comments to the header file.
takis
parents:
280
diff
changeset
|
116 /** |
633 | 117 * Frees a memory block which has been allocated with av_malloc(z)() or |
118 * av_realloc() and set the pointer pointing to it to NULL. | |
399
ae3fbcfbad4c
Doxyfication, patch by Stefano Sabatini %stefano P sabatini-lala A poste P it%
gpoirier
parents:
398
diff
changeset
|
119 * @param ptr Pointer to the pointer to the memory block which should |
ae3fbcfbad4c
Doxyfication, patch by Stefano Sabatini %stefano P sabatini-lala A poste P it%
gpoirier
parents:
398
diff
changeset
|
120 * be freed. |
ae3fbcfbad4c
Doxyfication, patch by Stefano Sabatini %stefano P sabatini-lala A poste P it%
gpoirier
parents:
398
diff
changeset
|
121 * @see av_free() |
281
411c8cbd578a
Move unaltered av_freep() comments to the header file.
takis
parents:
280
diff
changeset
|
122 */ |
113 | 123 void av_freep(void *ptr); |
124 | |
567 | 125 #endif /* AVUTIL_MEM_H */ |