From bdfb52193b5a2c5e44969b11d997ce19f0310af9 Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Sun, 13 Feb 2011 21:36:03 -0800 Subject: Replace _XkbDupString with Xstrdup The two functions have identical semantics, including safely returning NULL when NULL is passed in (which POSIX strdup does not guarantee). Some callers could probably be adjusted to call libc strdup directly, when we know the input is non-NULL. Signed-off-by: Alan Coopersmith Signed-off-by: Peter Hutterer Reviewed-by: Daniel Stone Backported-to-NX-by: Ulrich Sibiller --- nx-X11/programs/Xserver/xkb/xkb.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'nx-X11/programs/Xserver/xkb/xkb.c') diff --git a/nx-X11/programs/Xserver/xkb/xkb.c b/nx-X11/programs/Xserver/xkb/xkb.c index 47f4a2f96..b41548b83 100644 --- a/nx-X11/programs/Xserver/xkb/xkb.c +++ b/nx-X11/programs/Xserver/xkb/xkb.c @@ -5164,17 +5164,17 @@ ProcXkbGetKbdByName(ClientPtr client) if (!names.keymap) { if ((!names.compat)&& (fwant&(XkbGBN_CompatMapMask|XkbGBN_IndicatorMapMask))) { - names.compat= _XkbDupString("%"); + names.compat= Xstrdup("%"); } if ((!names.types)&&(fwant&(XkbGBN_TypesMask))) { - names.types= _XkbDupString("%"); + names.types= Xstrdup("%"); } if ((!names.symbols)&&(fwant&XkbGBN_SymbolsMask)) { - names.symbols= _XkbDupString("%"); + names.symbols= Xstrdup("%"); } geom_changed= ((names.geometry!=NULL)&&(strcmp(names.geometry,"%")!=0)); if ((!names.geometry)&&(fwant&XkbGBN_GeometryMask)) { - names.geometry= _XkbDupString("%"); + names.geometry= Xstrdup("%"); geom_changed= False; } } -- cgit v1.2.3 From 06bb154df0a4d6e35885bce6a63057bd8f8636e8 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Thu, 2 Mar 2017 15:38:08 +0100 Subject: replace (DE)ALLOCATE_LOCAL by malloc/free This is basically a backport of the following commits + replacing xalloc/xfree by malloc/free. Fixes ArcticaProject/nx-libs#358. commit 2761c103311a1160bc483fd0367d654733df8598 Author: Daniel Stone Date: Mon Nov 5 14:03:26 2007 +0000 OS: Remove usage of alloca Replace with heap allocations. commit 5e363500c86042c394595e1a6633581eb8fcd1bb Author: Daniel Stone Date: Mon Nov 5 14:38:28 2007 +0000 OS: Remove ALLOCATE_LOCAL from os.h Remove ALLOCATE_LOCAL_FALLBACK and DEALLOCATE_LOCAL_FALLBACK from os.h, and remove the include of Xalloca.h as well. --- nx-X11/programs/Xserver/xkb/xkb.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'nx-X11/programs/Xserver/xkb/xkb.c') diff --git a/nx-X11/programs/Xserver/xkb/xkb.c b/nx-X11/programs/Xserver/xkb/xkb.c index b41548b83..6798f2dda 100644 --- a/nx-X11/programs/Xserver/xkb/xkb.c +++ b/nx-X11/programs/Xserver/xkb/xkb.c @@ -1301,7 +1301,7 @@ unsigned i,len; char *desc,*start; len= (rep->length*4)-(SIZEOF(xkbGetMapReply)-SIZEOF(xGenericReply)); - start= desc= (char *)ALLOCATE_LOCAL(len); + start= desc= (char *)malloc(len); if (!start) return BadAlloc; memset(start, 0, len); @@ -1342,7 +1342,7 @@ char *desc,*start; } WriteToClient(client, (i=SIZEOF(xkbGetMapReply)), rep); WriteToClient(client, len, start); - DEALLOCATE_LOCAL((char *)start); + free((char *)start); return client->noClientException; } @@ -2486,7 +2486,7 @@ int size; size= rep->length*4; if (size>0) { - data = (char *)ALLOCATE_LOCAL(size); + data = (char *)malloc(size); if (data) { register unsigned i,bit; xkbModsWireDesc * grp; @@ -2534,7 +2534,7 @@ int size; WriteToClient(client, SIZEOF(xkbGetCompatMapReply), rep); if (data) { WriteToClient(client, size, data); - DEALLOCATE_LOCAL((char *)data); + free((char *)data); } return client->noClientException; } @@ -2781,7 +2781,7 @@ register unsigned bit; length = rep->length*4; if (length>0) { CARD8 *to; - to= map= (CARD8 *)ALLOCATE_LOCAL(length); + to= map= (CARD8 *)malloc(length); if (map) { xkbIndicatorMapWireDesc *wire = (xkbIndicatorMapWireDesc *)to; for (i=0,bit=1;inoClientException; } @@ -3308,7 +3308,7 @@ char * desc; swapl(&rep->indicators); } - start = desc = (char *)ALLOCATE_LOCAL(length); + start = desc = (char *)malloc(length); if ( !start ) return BadAlloc; if (which&XkbKeycodesNameMask) { @@ -3429,7 +3429,7 @@ char * desc; } WriteToClient(client, SIZEOF(xkbGetNamesReply), rep); WriteToClient(client, length, start); - DEALLOCATE_LOCAL((char *)start); + free((char *)start); return client->noClientException; } @@ -4315,7 +4315,7 @@ XkbSendGeometry( ClientPtr client, if (geom!=NULL) { len= rep->length*4; - start= desc= (char *)ALLOCATE_LOCAL(len); + start= desc= (char *)malloc(len); if (!start) return BadAlloc; desc= XkbWriteCountedString(desc,geom->label_font,client->swapped); @@ -4358,7 +4358,7 @@ XkbSendGeometry( ClientPtr client, if (len>0) WriteToClient(client, len, start); if (start!=NULL) - DEALLOCATE_LOCAL((char *)start); + free((char *)start); if (freeGeom) XkbFreeGeometry(geom,XkbGeomAllMask,True); return client->noClientException; @@ -5753,12 +5753,12 @@ char * str; } WriteToClient(client,SIZEOF(xkbGetDeviceInfoReply), &rep); - str= (char*) ALLOCATE_LOCAL(nameLen); + str= (char*) malloc(nameLen); if (!str) return BadAlloc; XkbWriteCountedString(str,dev->name,client->swapped); WriteToClient(client,nameLen,str); - DEALLOCATE_LOCAL(str); + free(str); length-= nameLen; if (rep.nBtnsRtrn>0) { -- cgit v1.2.3