summaryrefslogtreecommitdiff
path: root/gdk/gdkimage.c
diff options
context:
space:
mode:
authorOwen Taylor <otaylor@redhat.com>1998-09-15 17:08:38 +0000
committerOwen Taylor <otaylor@src.gnome.org>1998-09-15 17:08:38 +0000
commiteacc9f5d0585708e71ae822a6404c2fd62e0cf15 (patch)
treed4994073c8cd8a3c364360aacf1a07c26065144a /gdk/gdkimage.c
parenta2524578cd3848e83496e9fa9428e9ccb40ba1e6 (diff)
downloadgtk+-eacc9f5d0585708e71ae822a6404c2fd62e0cf15.tar.gz
Reverted global changes of g_new to malloc(), added back in the one place
Tue Sep 15 13:09:24 1998 Owen Taylor <otaylor@redhat.com> * gdk/gdkimage.c (gdk_image_new): Reverted global changes of g_new to malloc(), added back in the one place where it actually mattered. #include <stdlib.h>. * gdk/gdkrgb.c: g_malloc() to malloc() as above.
Diffstat (limited to 'gdk/gdkimage.c')
-rw-r--r--gdk/gdkimage.c37
1 files changed, 21 insertions, 16 deletions
diff --git a/gdk/gdkimage.c b/gdk/gdkimage.c
index c7f426581a..5c7a5de5c1 100644
--- a/gdk/gdkimage.c
+++ b/gdk/gdkimage.c
@@ -18,6 +18,7 @@
*/
#include "../config.h"
+#include <stdlib.h>
#include <sys/types.h>
#if defined (HAVE_IPC_H) && defined (HAVE_SHM_H) && defined (HAVE_XSHM_H)
@@ -84,7 +85,7 @@ gdk_image_new_bitmap(GdkVisual *visual, gpointer data, gint w, gint h)
Visual *xvisual;
GdkImage *image;
GdkImagePrivate *private;
- private = malloc (sizeof (GdkImagePrivate));
+ private = g_new(GdkImagePrivate, 1);
image = (GdkImage *) private;
private->xdisplay = gdk_display;
private->image_put = gdk_image_put_normal;
@@ -165,7 +166,7 @@ gdk_image_new (GdkImageType type,
break;
default:
- private = malloc (sizeof (GdkImagePrivate));
+ private = g_new (GdkImagePrivate, 1);
image = (GdkImage*) private;
private->xdisplay = gdk_display;
@@ -187,7 +188,7 @@ gdk_image_new (GdkImageType type,
{
private->image_put = gdk_image_put_shared;
- private->x_shm_info = malloc (sizeof (XShmSegmentInfo));
+ private->x_shm_info = g_new (XShmSegmentInfo, 1);
x_shm_info = private->x_shm_info;
private->ximage = XShmCreateImage (private->xdisplay, xvisual, visual->depth,
@@ -196,7 +197,7 @@ gdk_image_new (GdkImageType type,
{
g_warning ("XShmCreateImage failed");
- free (image);
+ g_free (image);
gdk_use_xshm = False;
return NULL;
}
@@ -210,8 +211,8 @@ gdk_image_new (GdkImageType type,
g_warning ("shmget failed!");
XDestroyImage (private->ximage);
- free (private->x_shm_info);
- free (image);
+ g_free (private->x_shm_info);
+ g_free (image);
gdk_use_xshm = False;
return NULL;
@@ -228,8 +229,8 @@ gdk_image_new (GdkImageType type,
XDestroyImage (private->ximage);
shmctl (x_shm_info->shmid, IPC_RMID, 0);
- free (private->x_shm_info);
- free (image);
+ g_free (private->x_shm_info);
+ g_free (image);
return NULL;
}
@@ -253,8 +254,8 @@ gdk_image_new (GdkImageType type,
shmdt (x_shm_info->shmaddr);
shmctl (x_shm_info->shmid, IPC_RMID, 0);
- free (private->x_shm_info);
- free (image);
+ g_free (private->x_shm_info);
+ g_free (image);
gdk_use_xshm = False;
return NULL;
@@ -265,12 +266,12 @@ gdk_image_new (GdkImageType type,
}
else
{
- free (image);
+ g_free (image);
return NULL;
}
break;
#else /* USE_SHM */
- free (image);
+ g_free (image);
return NULL;
#endif /* USE_SHM */
case GDK_IMAGE_NORMAL:
@@ -279,7 +280,11 @@ gdk_image_new (GdkImageType type,
private->ximage = XCreateImage (private->xdisplay, xvisual, visual->depth,
ZPixmap, 0, 0, width, height, 32, 0);
- private->ximage->data = malloc (sizeof (char) * private->ximage->bytes_per_line * private->ximage->height);
+ /* Use malloc, not g_malloc here, because X will call free()
+ * on this data
+ */
+ private->ximage->data = malloc (private->ximage->bytes_per_line *
+ private->ximage->height);
break;
case GDK_IMAGE_FASTEST:
@@ -330,7 +335,7 @@ gdk_image_get (GdkWindow *window,
if (win_private->destroyed)
return NULL;
- private = malloc (sizeof (GdkImagePrivate));
+ private = g_new (GdkImagePrivate, 1);
image = (GdkImage*) private;
private->xdisplay = gdk_display;
@@ -411,7 +416,7 @@ gdk_image_destroy (GdkImage *image)
shmdt (x_shm_info->shmaddr);
shmctl (x_shm_info->shmid, IPC_RMID, 0);
- free (private->x_shm_info);
+ g_free (private->x_shm_info);
image_list = g_list_remove (image_list, image);
#else /* USE_SHM */
@@ -423,7 +428,7 @@ gdk_image_destroy (GdkImage *image)
g_assert_not_reached ();
}
- free (image);
+ g_free (image);
}
static void