From 46e4cd640c247ace1ab16c63b157c0608161806e Mon Sep 17 00:00:00 2001 From: Ian C Date: Thu, 12 May 2005 23:21:03 +0000 Subject: Fixed problem with disabling shared memory XImage --- Makefile | 4 ++-- Xbit.c | 15 ++++++++++++++- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 08ff199..73e24f4 100644 --- a/Makefile +++ b/Makefile @@ -18,7 +18,7 @@ # # ------------------------------------------------------------------------- # -# $Id: Makefile,v 1.1.1.1 2005-05-12 00:59:39 ianc Exp $ +# $Id: Makefile,v 1.2 2005-05-12 23:21:03 ianc Exp $ # @@ -58,4 +58,4 @@ $(EDIT).o: Xbit.h $(EDIT).c $(CC) $(OPTS) $(DIRS) -c $(EDIT).c clean: - -rm -f Xbit.o $(OBJ).o $(OBJ) $(EDIT).o $(EDIT) + -rm -f Xbit.o $(OBJ).o $(OBJ) $(EDIT).o $(EDIT) hisc.ll diff --git a/Xbit.c b/Xbit.c index 7c2322e..b4907fa 100644 --- a/Xbit.c +++ b/Xbit.c @@ -205,7 +205,20 @@ XImage *CreateXImage(void) if (!use_shm) { - if (!(p=malloc(current->pw*current->ph*(vinfo.bits_per_rgb/8)))) + switch(vinfo.depth) + { + case 8: + p=malloc(current->pw*current->ph*1); + break; + case 16: + p=malloc(current->pw*current->ph*2); + break; + default: + p=malloc(current->pw*current->ph*4); + break; + } + + if (!p) { fprintf(stderr,"%s(%d) : FATAL:%s\n",__FILE__,__LINE__, "Couldn't malloc() XImage data"); -- cgit v1.2.3