diff options
Diffstat (limited to 'xlib')
-rw-r--r-- | xlib/xcolors.c | 10 | ||||
-rw-r--r-- | xlib/xgc.c | 47 | ||||
-rw-r--r-- | xlib/xutil.c | 7 |
3 files changed, 47 insertions, 17 deletions
diff --git a/xlib/xcolors.c b/xlib/xcolors.c index 0120579..90a9a9a 100644 --- a/xlib/xcolors.c +++ b/xlib/xcolors.c @@ -9,10 +9,10 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: xcolors.c,v 1.7 2007/01/02 23:39:40 dkf Exp $ + * RCS: @(#) $Id: xcolors.c,v 1.9 2010/04/20 15:14:30 nijtmans Exp $ */ -#include <tkInt.h> +#include "tkInt.h" /* * This value will be set to the number of colors in the color table @@ -34,11 +34,11 @@ static int FindColor(const char *name, XColor *colorPtr); */ typedef struct { - char *name; + const char *name; unsigned char red, green, blue; } XColorEntry; -static XColorEntry xColors[] = { +static const XColorEntry xColors[] = { { "alice blue", 240, 248, 255 }, { "AliceBlue", 240, 248, 255 }, { "antique white", 250, 235, 215 }, @@ -825,7 +825,7 @@ FindColor( */ if (numXColors == 0) { - XColorEntry *ePtr; + const XColorEntry *ePtr; for (ePtr = xColors; ePtr->name != NULL; ePtr++) { numXColors++; } @@ -5,25 +5,30 @@ * contexts. * * Copyright (c) 1995-1996 Sun Microsystems, Inc. - * Copyright (c) 2002-2007 Daniel A. Steffen <das@users.sourceforge.net> + * Copyright (c) 2002-2009 Daniel A. Steffen <das@users.sourceforge.net> + * Copyright 2008-2009, Apple Inc. * * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: xgc.c,v 1.16 2007/12/13 15:29:45 dgp Exp $ + * RCS: @(#) $Id: xgc.c,v 1.18 2010/04/20 15:14:30 nijtmans Exp $ */ -#include <tkInt.h> +#include "tkInt.h" #if !defined(MAC_OSX_TK) # include <X11/Xlib.h> -#endif -#ifdef MAC_OSX_TK +# define gcCacheSize 0 +# define TkpInitGCCache(gc) +# define TkpFreeGCCache(gc) +# define TkpGetGCCache(gc) +#else # include <tkMacOSXInt.h> # include <X11/Xlib.h> # include <X11/X.h> # define Cursor XCursor # define Region XRegion +# define gcCacheSize sizeof(TkpGCCache) #endif @@ -47,7 +52,7 @@ static TkpClipMask *AllocClipMask(GC gc) { TkpClipMask *clip_mask = (TkpClipMask*) gc->clip_mask; if (clip_mask == None) { - clip_mask = (TkpClipMask*) ckalloc(sizeof(TkpClipMask)); + clip_mask = ckalloc(sizeof(TkpClipMask)); gc->clip_mask = (Pixmap) clip_mask; #ifdef MAC_OSX_TK } else if (clip_mask->type == TKP_CLIP_REGION) { @@ -80,7 +85,7 @@ static void FreeClipMask(GC gc) { TkpReleaseRegion(((TkpClipMask*) gc->clip_mask)->value.region); } #endif - ckfree((char*) gc->clip_mask); + ckfree(gc->clip_mask); gc->clip_mask = None; } } @@ -119,7 +124,7 @@ XCreateGC( #define MAX_DASH_LIST_SIZE 10 - gp = (XGCValues *) ckalloc(sizeof(XGCValues) + MAX_DASH_LIST_SIZE); + gp = ckalloc(sizeof(XGCValues) + MAX_DASH_LIST_SIZE + gcCacheSize); if (!gp) { return None; } @@ -160,10 +165,33 @@ XCreateGC( clip_mask->type = TKP_CLIP_PIXMAP; clip_mask->value.pixmap = values->clip_mask; } + TkpInitGCCache(gp); return gp; } +#ifdef MAC_OSX_TK +/* + *---------------------------------------------------------------------- + * + * TkpGetGCCache -- + * + * Results: + * Pointer to the TkpGCCache at the end of the GC. + * + * Side effects: + * None. + * + *---------------------------------------------------------------------- + */ + +TkpGCCache* +TkpGetGCCache(GC gc) { + return (gc ? (TkpGCCache*)(((char*) gc) + sizeof(XGCValues) + + MAX_DASH_LIST_SIZE) : NULL); +} +#endif + /* *---------------------------------------------------------------------- * @@ -242,7 +270,8 @@ void XFreeGC( { if (gc != None) { FreeClipMask(gc); - ckfree((char *) gc); + TkpFreeGCCache(gc); + ckfree(gc); } } diff --git a/xlib/xutil.c b/xlib/xutil.c index 103d995..b265e5d 100644 --- a/xlib/xutil.c +++ b/xlib/xutil.c @@ -8,7 +8,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: xutil.c,v 1.4 2007/01/02 23:39:40 dkf Exp $ + * RCS: @(#) $Id: xutil.c,v 1.5 2010/02/19 13:41:49 dkf Exp $ */ #include <stdlib.h> @@ -70,7 +70,8 @@ XGetVisualInfo( XVisualInfo *vinfo_template, int *nitems_return) { - XVisualInfo *info = (XVisualInfo *) ckalloc(sizeof(XVisualInfo)); + XVisualInfo *info = ckalloc(sizeof(XVisualInfo)); + info->visual = DefaultVisual(display, 0); info->visualid = info->visual->visualid; info->screen = 0; @@ -101,7 +102,7 @@ XGetVisualInfo( || ((vinfo_mask & VisualBlueMaskMask) && (vinfo_template->blue_mask != info->blue_mask)) ) { - ckfree((char *) info); + ckfree(info); return NULL; } |