annotate mem.h @ 478:8d2c05ebf5f1 libavutil

revert r12489.
author benoit
date Tue, 18 Mar 2008 16:29:47 +0000
parents 8d25a4b50588
children f4187c1c15a6
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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 /**
286
c1d6b0378055 Move the memory related functions out of common.h into their own header file
takis
parents: 284
diff changeset
22 * @file mem.h
c1d6b0378055 Move the memory related functions out of common.h into their own header file
takis
parents: 284
diff changeset
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
392
d0f3bb6e367e Add FFMPEG_ prefix to all multiple inclusion guards.
diego
parents: 390
diff changeset
26 #ifndef FFMPEG_MEM_H
d0f3bb6e367e Add FFMPEG_ prefix to all multiple inclusion guards.
diego
parents: 390
diff changeset
27 #define FFMPEG_MEM_H
104
5111e87117b7 Align the input buffer in ffplay, introduce a public macro for aligned declarations
lu_zero
parents: 100
diff changeset
28
448
41603959875e Disentangle nested preprocessor directives.
diego
parents: 447
diff changeset
29 #ifdef __ICC
455
ed36fc829044 cosmetics: prettyprint
diego
parents: 454
diff changeset
30 #define DECLARE_ALIGNED(n,t,v) t v __attribute__ ((aligned (n)))
ed36fc829044 cosmetics: prettyprint
diego
parents: 454
diff changeset
31 #define DECLARE_ASM_CONST(n,t,v) const t __attribute__ ((aligned (n))) v
454
909853728b47 10l: Correctly use preprocessor conditionals.
diego
parents: 450
diff changeset
32 #elif defined(__GNUC__)
455
ed36fc829044 cosmetics: prettyprint
diego
parents: 454
diff changeset
33 #define DECLARE_ALIGNED(n,t,v) t v __attribute__ ((aligned (n)))
ed36fc829044 cosmetics: prettyprint
diego
parents: 454
diff changeset
34 #define DECLARE_ASM_CONST(n,t,v) static const t v attribute_used __attribute__ ((aligned (n)))
457
b612613c38ba Fix MSVC identification, patch by Eddie Pang.
michael
parents: 456
diff changeset
35 #elif defined(_MSC_VER)
455
ed36fc829044 cosmetics: prettyprint
diego
parents: 454
diff changeset
36 #define DECLARE_ALIGNED(n,t,v) __declspec(align(n)) t v
ed36fc829044 cosmetics: prettyprint
diego
parents: 454
diff changeset
37 #define DECLARE_ASM_CONST(n,t,v) __declspec(align(n)) static const t v
465
b0b971f533e4 #error in case we do not know how to provide alignment.
diego
parents: 457
diff changeset
38 #elif defined(HAVE_INLINE_ASM)
b0b971f533e4 #error in case we do not know how to provide alignment.
diego
parents: 457
diff changeset
39 #error The asm code needs alignment, but we do not know how to do it for this compiler.
450
dd654d025ed5 Add fallback for DECLARE_ALIGNED and DECLARE_ASM_CONST.
diego
parents: 449
diff changeset
40 #else
455
ed36fc829044 cosmetics: prettyprint
diego
parents: 454
diff changeset
41 #define DECLARE_ALIGNED(n,t,v) t v
ed36fc829044 cosmetics: prettyprint
diego
parents: 454
diff changeset
42 #define DECLARE_ASM_CONST(n,t,v) static const t v
104
5111e87117b7 Align the input buffer in ffplay, introduce a public macro for aligned declarations
lu_zero
parents: 100
diff changeset
43 #endif
5111e87117b7 Align the input buffer in ffplay, introduce a public macro for aligned declarations
lu_zero
parents: 100
diff changeset
44
278
ca3eb39d3aa2 Move unaltered av_malloc() comments to the header file.
takis
parents: 252
diff changeset
45 /**
399
ae3fbcfbad4c Doxyfication, patch by Stefano Sabatini %stefano P sabatini-lala A poste P it%
gpoirier
parents: 398
diff changeset
46 * Allocate a block of \p size bytes with alignment suitable for all
ae3fbcfbad4c Doxyfication, patch by Stefano Sabatini %stefano P sabatini-lala A poste P it%
gpoirier
parents: 398
diff changeset
47 * 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
48 * @param size Size in bytes for the memory block to be allocated.
ae3fbcfbad4c Doxyfication, patch by Stefano Sabatini %stefano P sabatini-lala A poste P it%
gpoirier
parents: 398
diff changeset
49 * @return Pointer to the allocated block, NULL if it cannot allocate
ae3fbcfbad4c Doxyfication, patch by Stefano Sabatini %stefano P sabatini-lala A poste P it%
gpoirier
parents: 398
diff changeset
50 * it.
ae3fbcfbad4c Doxyfication, patch by Stefano Sabatini %stefano P sabatini-lala A poste P it%
gpoirier
parents: 398
diff changeset
51 * @see av_mallocz()
278
ca3eb39d3aa2 Move unaltered av_malloc() comments to the header file.
takis
parents: 252
diff changeset
52 */
478
8d2c05ebf5f1 revert r12489.
benoit
parents: 477
diff changeset
53 void *av_malloc(unsigned int size);
279
4964532166e6 Move unaltered av_realloc() comments to the header file.
takis
parents: 278
diff changeset
54
4964532166e6 Move unaltered av_realloc() comments to the header file.
takis
parents: 278
diff changeset
55 /**
399
ae3fbcfbad4c Doxyfication, patch by Stefano Sabatini %stefano P sabatini-lala A poste P it%
gpoirier
parents: 398
diff changeset
56 * Allocate or reallocate a block of memory.
ae3fbcfbad4c Doxyfication, patch by Stefano Sabatini %stefano P sabatini-lala A poste P it%
gpoirier
parents: 398
diff changeset
57 * If \p ptr is NULL and \p size > 0, allocate a new block. If \p
ae3fbcfbad4c Doxyfication, patch by Stefano Sabatini %stefano P sabatini-lala A poste P it%
gpoirier
parents: 398
diff changeset
58 * size is zero, free the memory block pointed by \p ptr.
ae3fbcfbad4c Doxyfication, patch by Stefano Sabatini %stefano P sabatini-lala A poste P it%
gpoirier
parents: 398
diff changeset
59 * @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
60 * reallocated.
ae3fbcfbad4c Doxyfication, patch by Stefano Sabatini %stefano P sabatini-lala A poste P it%
gpoirier
parents: 398
diff changeset
61 * @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
62 * av_malloc(z)() or av_realloc() or NULL.
ae3fbcfbad4c Doxyfication, patch by Stefano Sabatini %stefano P sabatini-lala A poste P it%
gpoirier
parents: 398
diff changeset
63 * @return Pointer to a newly reallocated block or NULL if it cannot
ae3fbcfbad4c Doxyfication, patch by Stefano Sabatini %stefano P sabatini-lala A poste P it%
gpoirier
parents: 398
diff changeset
64 * reallocate or the function is used to free the memory block.
ae3fbcfbad4c Doxyfication, patch by Stefano Sabatini %stefano P sabatini-lala A poste P it%
gpoirier
parents: 398
diff changeset
65 * @see av_fast_realloc()
279
4964532166e6 Move unaltered av_realloc() comments to the header file.
takis
parents: 278
diff changeset
66 */
82
8fb151c4d4c7 Move av_malloc(), av_realloc(), and av_free() from libavcodec to libavutil
lucabe
parents: 80
diff changeset
67 void *av_realloc(void *ptr, unsigned int size);
280
8c22d0665daa Move unaltered av_free() comments to the header file.
takis
parents: 279
diff changeset
68
8c22d0665daa Move unaltered av_free() comments to the header file.
takis
parents: 279
diff changeset
69 /**
399
ae3fbcfbad4c Doxyfication, patch by Stefano Sabatini %stefano P sabatini-lala A poste P it%
gpoirier
parents: 398
diff changeset
70 * Free a memory block which has been allocated with av_malloc(z)() or
ae3fbcfbad4c Doxyfication, patch by Stefano Sabatini %stefano P sabatini-lala A poste P it%
gpoirier
parents: 398
diff changeset
71 * av_realloc().
ae3fbcfbad4c Doxyfication, patch by Stefano Sabatini %stefano P sabatini-lala A poste P it%
gpoirier
parents: 398
diff changeset
72 * @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
73 * @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
74 * @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
75 * @see av_freep()
280
8c22d0665daa Move unaltered av_free() comments to the header file.
takis
parents: 279
diff changeset
76 */
82
8fb151c4d4c7 Move av_malloc(), av_realloc(), and av_free() from libavcodec to libavutil
lucabe
parents: 80
diff changeset
77 void av_free(void *ptr);
8fb151c4d4c7 Move av_malloc(), av_realloc(), and av_free() from libavcodec to libavutil
lucabe
parents: 80
diff changeset
78
399
ae3fbcfbad4c Doxyfication, patch by Stefano Sabatini %stefano P sabatini-lala A poste P it%
gpoirier
parents: 398
diff changeset
79 /**
ae3fbcfbad4c Doxyfication, patch by Stefano Sabatini %stefano P sabatini-lala A poste P it%
gpoirier
parents: 398
diff changeset
80 * Allocate a block of \p size bytes with alignment suitable for all
ae3fbcfbad4c Doxyfication, patch by Stefano Sabatini %stefano P sabatini-lala A poste P it%
gpoirier
parents: 398
diff changeset
81 * memory accesses (including vectors if available on the CPU) and
ae3fbcfbad4c Doxyfication, patch by Stefano Sabatini %stefano P sabatini-lala A poste P it%
gpoirier
parents: 398
diff changeset
82 * set to zeroes all the bytes of the block.
ae3fbcfbad4c Doxyfication, patch by Stefano Sabatini %stefano P sabatini-lala A poste P it%
gpoirier
parents: 398
diff changeset
83 * @param size Size in bytes for the memory block to be allocated.
ae3fbcfbad4c Doxyfication, patch by Stefano Sabatini %stefano P sabatini-lala A poste P it%
gpoirier
parents: 398
diff changeset
84 * @return Pointer to the allocated block, NULL if it cannot allocate
ae3fbcfbad4c Doxyfication, patch by Stefano Sabatini %stefano P sabatini-lala A poste P it%
gpoirier
parents: 398
diff changeset
85 * it.
ae3fbcfbad4c Doxyfication, patch by Stefano Sabatini %stefano P sabatini-lala A poste P it%
gpoirier
parents: 398
diff changeset
86 * @see av_malloc()
ae3fbcfbad4c Doxyfication, patch by Stefano Sabatini %stefano P sabatini-lala A poste P it%
gpoirier
parents: 398
diff changeset
87 */
478
8d2c05ebf5f1 revert r12489.
benoit
parents: 477
diff changeset
88 void *av_mallocz(unsigned int size);
382
6224c028828a Document libavutil/mem.h:av_strdup.
diego
parents: 286
diff changeset
89
6224c028828a Document libavutil/mem.h:av_strdup.
diego
parents: 286
diff changeset
90 /**
390
0fc1d6548be4 misc Doxygen spelling/grammar fixes
diego
parents: 382
diff changeset
91 * Duplicate the string \p s.
382
6224c028828a Document libavutil/mem.h:av_strdup.
diego
parents: 286
diff changeset
92 * @param s String to be duplicated.
6224c028828a Document libavutil/mem.h:av_strdup.
diego
parents: 286
diff changeset
93 * @return Pointer to a newly allocated string containing a
390
0fc1d6548be4 misc Doxygen spelling/grammar fixes
diego
parents: 382
diff changeset
94 * copy of \p s or NULL if it cannot be allocated.
382
6224c028828a Document libavutil/mem.h:av_strdup.
diego
parents: 286
diff changeset
95 */
478
8d2c05ebf5f1 revert r12489.
benoit
parents: 477
diff changeset
96 char *av_strdup(const char *s);
281
411c8cbd578a Move unaltered av_freep() comments to the header file.
takis
parents: 280
diff changeset
97
411c8cbd578a Move unaltered av_freep() comments to the header file.
takis
parents: 280
diff changeset
98 /**
399
ae3fbcfbad4c Doxyfication, patch by Stefano Sabatini %stefano P sabatini-lala A poste P it%
gpoirier
parents: 398
diff changeset
99 * Free a memory block which has been allocated with av_malloc(z)() or
ae3fbcfbad4c Doxyfication, patch by Stefano Sabatini %stefano P sabatini-lala A poste P it%
gpoirier
parents: 398
diff changeset
100 * av_realloc() and set to NULL the pointer to it.
ae3fbcfbad4c Doxyfication, patch by Stefano Sabatini %stefano P sabatini-lala A poste P it%
gpoirier
parents: 398
diff changeset
101 * @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
102 * be freed.
ae3fbcfbad4c Doxyfication, patch by Stefano Sabatini %stefano P sabatini-lala A poste P it%
gpoirier
parents: 398
diff changeset
103 * @see av_free()
281
411c8cbd578a Move unaltered av_freep() comments to the header file.
takis
parents: 280
diff changeset
104 */
113
8fc54918226e move memory functions from avcodec to avutil
lu_zero
parents: 112
diff changeset
105 void av_freep(void *ptr);
8fc54918226e move memory functions from avcodec to avutil
lu_zero
parents: 112
diff changeset
106
392
d0f3bb6e367e Add FFMPEG_ prefix to all multiple inclusion guards.
diego
parents: 390
diff changeset
107 #endif /* FFMPEG_MEM_H */