#undef DEBUG_ANI
-#include <config.h>
+#include "config.h"
#include <stdlib.h>
#include <string.h>
#include "gdk-pixbuf-private.h"
{
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;
}
(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 ||
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;
}
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;
}
{
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++)
{
{
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
}
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
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;
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;
}
}
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;
}
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;
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 },