Move *_static to bitstream.c which is the only file left which needs
authorMichael Niedermayer <michaelni@gmx.at>
Fri, 30 May 2008 21:12:33 +0000 (21:12 +0000)
committerMichael Niedermayer <michaelni@gmx.at>
Fri, 30 May 2008 21:12:33 +0000 (21:12 +0000)
them.

Originally committed as revision 13568 to svn://svn.ffmpeg.org/ffmpeg/trunk

libavcodec/avcodec.h
libavcodec/bitstream.c
libavcodec/utils.c

index 6aa71ba01140a69095251b9df686e3a25a4d9083..2cf360fbcfc3da162e69b572c0907b468860040f 100644 (file)
@@ -2918,31 +2918,6 @@ AVBitStreamFilter *av_bitstream_filter_next(AVBitStreamFilter *f);
  */
 void *av_fast_realloc(void *ptr, unsigned int *size, unsigned int min_size);
 
-/* for static data only */
-
-/**
- * Frees all static arrays and resets their pointers to 0.
- * Call this function to release all statically allocated tables.
- *
- * @deprecated. Code which uses av_free_static is broken/misdesigned
- * and should correctly use static arrays
- *
- */
-attribute_deprecated void av_free_static(void);
-
-/**
- * Allocation of static arrays.
- *
- * @warning Do not use for normal allocation.
- *
- * @param[in] size The amount of memory you need in bytes.
- * @return block of memory of the requested size
- * @deprecated. Code which uses av_mallocz_static is broken/misdesigned
- * and should correctly use static arrays
- */
-attribute_deprecated av_malloc_attrib av_alloc_size(1)
-void *av_mallocz_static(unsigned int size);
-
 /**
  * Copy image 'src' to 'dst'.
  */
index 823bf97f4f13cfaf8d6d05ef58674110fefee566..7c8cca2abe83bc8d8ca130c25126f9b64386a57d 100644 (file)
  * and should correctly use static arrays
  */
 attribute_deprecated av_alloc_size(2)
-void *ff_realloc_static(void *ptr, unsigned int size);
+static void *ff_realloc_static(void *ptr, unsigned int size);
+
+static unsigned int last_static = 0;
+static unsigned int allocated_static = 0;
+static void** array_static = NULL;
+
+static void *av_mallocz_static(unsigned int size)
+{
+    void *ptr = av_mallocz(size);
+
+    if(ptr){
+        array_static =av_fast_realloc(array_static, &allocated_static, sizeof(void*)*(last_static+1));
+        if(!array_static)
+            return NULL;
+        array_static[last_static++] = ptr;
+    }
+
+    return ptr;
+}
+
+static void *ff_realloc_static(void *ptr, unsigned int size)
+{
+    int i;
+    if(!ptr)
+      return av_mallocz_static(size);
+    /* Look for the old ptr */
+    for(i = 0; i < last_static; i++) {
+        if(array_static[i] == ptr) {
+            array_static[i] = av_realloc(array_static[i], size);
+            return array_static[i];
+        }
+    }
+    return NULL;
+
+}
+
+static void av_free_static(void)
+{
+    while(last_static){
+        av_freep(&array_static[--last_static]);
+    }
+    av_freep(&array_static);
+}
+
+/**
+ * Call av_free_static automatically before it's too late
+ */
+
+static void do_free(void) __attribute__ ((destructor));
+
+static void do_free(void)
+{
+    av_free_static();
+}
+
 
 void align_put_bits(PutBitContext *s)
 {
index 3fd5eb33190419a63db6ea9a435db0c523edef20..a245b90fc86a352b3502f4ac8793421fa012c0d4 100644 (file)
@@ -73,60 +73,6 @@ void *av_fast_realloc(void *ptr, unsigned int *size, unsigned int min_size)
     return ptr;
 }
 
-static unsigned int last_static = 0;
-static unsigned int allocated_static = 0;
-static void** array_static = NULL;
-
-void *av_mallocz_static(unsigned int size)
-{
-    void *ptr = av_mallocz(size);
-
-    if(ptr){
-        array_static =av_fast_realloc(array_static, &allocated_static, sizeof(void*)*(last_static+1));
-        if(!array_static)
-            return NULL;
-        array_static[last_static++] = ptr;
-    }
-
-    return ptr;
-}
-
-void *ff_realloc_static(void *ptr, unsigned int size)
-{
-    int i;
-    if(!ptr)
-      return av_mallocz_static(size);
-    /* Look for the old ptr */
-    for(i = 0; i < last_static; i++) {
-        if(array_static[i] == ptr) {
-            array_static[i] = av_realloc(array_static[i], size);
-            return array_static[i];
-        }
-    }
-    return NULL;
-
-}
-
-void av_free_static(void)
-{
-    while(last_static){
-        av_freep(&array_static[--last_static]);
-    }
-    av_freep(&array_static);
-}
-
-/**
- * Call av_free_static automatically before it's too late
- */
-
-static void do_free(void) __attribute__ ((destructor));
-
-static void do_free(void)
-{
-    av_free_static();
-}
-
-
 /* encoder management */
 AVCodec *first_avcodec = NULL;