]> Pileus Git - ~andy/gtk/blobdiff - gdk-pixbuf/io-ani.c
[quartz] Delete the typedef of GdkDevicePrivate
[~andy/gtk] / gdk-pixbuf / io-ani.c
index 5568ad65d445a706c68d91d5ee66f580bab98dc5..0f4286852386623076d5e3cb69efc8866a4ae97b 100644 (file)
@@ -23,7 +23,7 @@
 
 #undef DEBUG_ANI
 
-#include <config.h>
+#include "config.h"
 #include <stdlib.h>
 #include <string.h>
 #include "gdk-pixbuf-private.h"
@@ -238,10 +238,10 @@ ani_load_chunk (AniLoaderContext *context, GError **error)
                {
                        if (context->pos >= context->NumFrames) 
                        {
-                               g_set_error (error,
-                                            GDK_PIXBUF_ERROR,
-                                            GDK_PIXBUF_ERROR_CORRUPT_IMAGE,
-                                            _("Unexpected icon chunk in animation"));
+                               g_set_error_literal (error,
+                                                     GDK_PIXBUF_ERROR,
+                                                     GDK_PIXBUF_ERROR_CORRUPT_IMAGE,
+                                                     _("Unexpected icon chunk in animation"));
                                return FALSE; 
                        }
 
@@ -329,12 +329,12 @@ ani_load_chunk (AniLoaderContext *context, GError **error)
                         (context->Flags & 0x2) != 0, 
                         (context->Flags & 0x1) != 0);
 #endif
-               if (!context->Flags & 0x2) 
+               if (!(context->Flags & 0x2))
                {
-                       g_set_error (error,
-                                    GDK_PIXBUF_ERROR,
-                                    GDK_PIXBUF_ERROR_CORRUPT_IMAGE,
-                                    _("Unsupported animation type"));
+                       g_set_error_literal (error,
+                                             GDK_PIXBUF_ERROR,
+                                             GDK_PIXBUF_ERROR_CORRUPT_IMAGE,
+                                             _("Unsupported animation type"));
                        return FALSE; 
                }
                if (context->NumFrames == 0 || 
@@ -342,20 +342,20 @@ ani_load_chunk (AniLoaderContext *context, GError **error)
                    context->NumSteps == 0 || 
                    context->NumSteps >= 1024) 
                {
-                       g_set_error (error,
-                                    GDK_PIXBUF_ERROR,
-                                    GDK_PIXBUF_ERROR_CORRUPT_IMAGE,
-                                    _("Invalid header in animation"));
+                       g_set_error_literal (error,
+                                             GDK_PIXBUF_ERROR,
+                                             GDK_PIXBUF_ERROR_CORRUPT_IMAGE,
+                                             _("Invalid header in animation"));
                        return FALSE;
                }
       
                context->animation = g_object_new (GDK_TYPE_PIXBUF_ANI_ANIM, NULL);        
                if (!context->animation) 
                {
-                       g_set_error (error,
-                                    GDK_PIXBUF_ERROR,
-                                    GDK_PIXBUF_ERROR_INSUFFICIENT_MEMORY,
-                                    _("Not enough memory to load animation"));
+                       g_set_error_literal (error,
+                                             GDK_PIXBUF_ERROR,
+                                             GDK_PIXBUF_ERROR_INSUFFICIENT_MEMORY,
+                                             _("Not enough memory to load animation"));
                        return FALSE;
                }
 
@@ -366,20 +366,18 @@ ani_load_chunk (AniLoaderContext *context, GError **error)
                context->animation->width = 0;
                context->animation->height = 0;
 
-               context->animation->pixbufs = (GdkPixbuf**) g_try_malloc (sizeof (GdkPixbuf*) * context->NumFrames);
-               if (context->animation->pixbufs) 
-                       memset (context->animation->pixbufs, 0, sizeof (GdkPixbuf*) * context->NumFrames);
-                                                
-               context->animation->delay = (guint32*) g_try_malloc (sizeof (guint32) * context->NumSteps);
-               context->animation->sequence = (guint32*) g_try_malloc (sizeof (guint32) * context->NumSteps);
+               context->animation->pixbufs = g_try_new0 (GdkPixbuf*, context->NumFrames);
+               context->animation->delay = g_try_new (gint, context->NumSteps);
+               context->animation->sequence = g_try_new (gint, context->NumSteps);
+
                if (!context->animation->pixbufs || 
                    !context->animation->delay || 
                    !context->animation->sequence) 
                {
-                       g_set_error (error,
-                                    GDK_PIXBUF_ERROR,
-                                    GDK_PIXBUF_ERROR_INSUFFICIENT_MEMORY,
-                                    _("Not enough memory to load animation"));
+                       g_set_error_literal (error,
+                                             GDK_PIXBUF_ERROR,
+                                             GDK_PIXBUF_ERROR_INSUFFICIENT_MEMORY,
+                                             _("Not enough memory to load animation"));
                        return FALSE;
                }
 
@@ -394,12 +392,21 @@ ani_load_chunk (AniLoaderContext *context, GError **error)
        {
                if (context->chunk_size != 4 * context->NumSteps) 
                {
-                       g_set_error (error,
-                                    GDK_PIXBUF_ERROR,
-                                    GDK_PIXBUF_ERROR_CORRUPT_IMAGE,
-                                    _("Malformed chunk in animation"));
+                       g_set_error_literal (error,
+                                             GDK_PIXBUF_ERROR,
+                                             GDK_PIXBUF_ERROR_CORRUPT_IMAGE,
+                                             _("Malformed chunk in animation"));
                        return FALSE; 
                }
+               if (!context->animation) 
+               {
+                       g_set_error_literal (error,
+                                             GDK_PIXBUF_ERROR,
+                                             GDK_PIXBUF_ERROR_CORRUPT_IMAGE,
+                                             _("Invalid header in animation"));
+                       return FALSE;
+               }
+
                context->animation->total_time = 0;
                for (i = 0; i < context->NumSteps; i++) 
                {
@@ -411,38 +418,54 @@ ani_load_chunk (AniLoaderContext *context, GError **error)
        {
                if (context->chunk_size != 4 * context->NumSteps) 
                {
-                       g_set_error (error,
-                                    GDK_PIXBUF_ERROR,
-                                    GDK_PIXBUF_ERROR_CORRUPT_IMAGE,
-                                    _("Malformed chunk in animation"));
+                       g_set_error_literal (error,
+                                             GDK_PIXBUF_ERROR,
+                                             GDK_PIXBUF_ERROR_CORRUPT_IMAGE,
+                                             _("Malformed chunk in animation"));
                        return FALSE; 
                }
+               if (!context->animation) 
+               {
+                       g_set_error_literal (error,
+                                             GDK_PIXBUF_ERROR,
+                                             GDK_PIXBUF_ERROR_CORRUPT_IMAGE,
+                                             _("Invalid header in animation"));
+                       return FALSE;
+               }
                for (i = 0; i < context->NumSteps; i++) 
                {
                        context->animation->sequence[i] = read_int32 (context);
                        if (context->animation->sequence[i] >= context->NumFrames) 
                        {
-                               g_set_error (error,
-                                            GDK_PIXBUF_ERROR,
-                                            GDK_PIXBUF_ERROR_CORRUPT_IMAGE,
-                                            _("Malformed chunk in animation"));
+                               g_set_error_literal (error,
+                                                     GDK_PIXBUF_ERROR,
+                                                     GDK_PIXBUF_ERROR_CORRUPT_IMAGE,
+                                                     _("Malformed chunk in animation"));
                                return FALSE; 
                        }
                }
        }
         else if (context->chunk_id == TAG_INAM) 
        {
+               if (!context->animation) 
+               {
+                       g_set_error_literal (error,
+                                             GDK_PIXBUF_ERROR,
+                                             GDK_PIXBUF_ERROR_CORRUPT_IMAGE,
+                                             _("Invalid header in animation"));
+                       return FALSE;
+               }
                context->title = g_try_malloc (context->chunk_size + 1);
                if (!context->title) 
                {
-                       g_set_error (error,
-                                    GDK_PIXBUF_ERROR,
-                                    GDK_PIXBUF_ERROR_INSUFFICIENT_MEMORY,
-                                    _("Not enough memory to load animation"));
+                       g_set_error_literal (error,
+                                             GDK_PIXBUF_ERROR,
+                                             GDK_PIXBUF_ERROR_INSUFFICIENT_MEMORY,
+                                             _("Not enough memory to load animation"));
                        return FALSE;
                }
                context->title[context->chunk_size] = 0;
-               read_int8 (context, context->title, context->chunk_size);
+               read_int8 (context, (guchar *)context->title, context->chunk_size);
 #ifdef DEBUG_ANI
                g_print ("INAM %s\n", context->title);
 #endif
@@ -451,17 +474,25 @@ ani_load_chunk (AniLoaderContext *context, GError **error)
        }
         else if (context->chunk_id == TAG_IART) 
        {
+               if (!context->animation) 
+               {
+                       g_set_error_literal (error,
+                                             GDK_PIXBUF_ERROR,
+                                             GDK_PIXBUF_ERROR_CORRUPT_IMAGE,
+                                             _("Invalid header in animation"));
+                       return FALSE;
+               }
                context->author = g_try_malloc (context->chunk_size + 1);
                if (!context->author) 
                {
-                       g_set_error (error,
-                                    GDK_PIXBUF_ERROR,
-                                    GDK_PIXBUF_ERROR_INSUFFICIENT_MEMORY,
-                                    _("Not enough memory to load animation"));
+                       g_set_error_literal (error,
+                                             GDK_PIXBUF_ERROR,
+                                             GDK_PIXBUF_ERROR_INSUFFICIENT_MEMORY,
+                                             _("Not enough memory to load animation"));
                        return FALSE;
                }
                context->author[context->chunk_size] = 0;
-               read_int8 (context, context->author, context->chunk_size);
+               read_int8 (context, (guchar *)context->author, context->chunk_size);
 #ifdef DEBUG_ANI
                g_print ("IART %s\n", context->author);
 #endif
@@ -505,10 +536,10 @@ gdk_pixbuf__ani_image_load_increment (gpointer data,
                         tmp = g_try_realloc (context->buffer, context->buffer_size);
                         if (!tmp) 
                        {
-                               g_set_error (error,
-                                            GDK_PIXBUF_ERROR,
-                                            GDK_PIXBUF_ERROR_INSUFFICIENT_MEMORY,
-                                            _("Not enough memory to load animation"));
+                               g_set_error_literal (error,
+                                                     GDK_PIXBUF_ERROR,
+                                                     GDK_PIXBUF_ERROR_INSUFFICIENT_MEMORY,
+                                                     _("Not enough memory to load animation"));
                                return FALSE;
                        }
                         context->byte = context->buffer = tmp;
@@ -532,10 +563,10 @@ gdk_pixbuf__ani_image_load_increment (gpointer data,
                    context->data_size == 0 || 
                    chunk_id != TAG_ACON) 
                {
-                       g_set_error (error,
-                                    GDK_PIXBUF_ERROR,
-                                    GDK_PIXBUF_ERROR_CORRUPT_IMAGE,
-                                    _("Invalid header in animation"));
+                       g_set_error_literal (error,
+                                             GDK_PIXBUF_ERROR,
+                                             GDK_PIXBUF_ERROR_CORRUPT_IMAGE,
+                                             _("Invalid header in animation"));
                        return FALSE; 
                }
        }
@@ -577,10 +608,10 @@ gdk_pixbuf__ani_image_begin_load (GdkPixbufModuleSizeFunc size_func,
         if (!context->buffer) 
        {
                context_free (context);
-               g_set_error (error,
-                            GDK_PIXBUF_ERROR,
-                            GDK_PIXBUF_ERROR_INSUFFICIENT_MEMORY,
-                            _("Not enough memory to load animation"));
+               g_set_error_literal (error,
+                                     GDK_PIXBUF_ERROR,
+                                     GDK_PIXBUF_ERROR_INSUFFICIENT_MEMORY,
+                                     _("Not enough memory to load animation"));
                return NULL;
        }
         
@@ -646,8 +677,13 @@ gdk_pixbuf__ani_image_load_animation (FILE *f, GError **error)
        return anim;
 }
 
-void
-MODULE_ENTRY (ani, fill_vtable) (GdkPixbufModule *module)
+#ifndef INCLUDE_ani
+#define MODULE_ENTRY(function) G_MODULE_EXPORT void function
+#else
+#define MODULE_ENTRY(function) void _gdk_pixbuf__ani_ ## function
+#endif
+
+MODULE_ENTRY (fill_vtable) (GdkPixbufModule *module)
 {
         module->load_animation = gdk_pixbuf__ani_image_load_animation;
         module->begin_load = gdk_pixbuf__ani_image_begin_load;
@@ -655,8 +691,7 @@ MODULE_ENTRY (ani, fill_vtable) (GdkPixbufModule *module)
         module->load_increment = gdk_pixbuf__ani_image_load_increment;
 }
 
-void
-MODULE_ENTRY (ani, fill_info) (GdkPixbufFormat *info)
+MODULE_ENTRY (fill_info) (GdkPixbufFormat *info)
 {
        static GdkPixbufModulePattern signature[] = {
                { "RIFF    ACON", "    xxxx    ", 100 },