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/record/record.c | 12 ++++++------ nx-X11/programs/Xserver/record/set.c | 7 ++----- 2 files changed, 8 insertions(+), 11 deletions(-) (limited to 'nx-X11/programs/Xserver/record') diff --git a/nx-X11/programs/Xserver/record/record.c b/nx-X11/programs/Xserver/record/record.c index eb9212f40..bf3f9decb 100644 --- a/nx-X11/programs/Xserver/record/record.c +++ b/nx-X11/programs/Xserver/record/record.c @@ -1763,7 +1763,7 @@ RecordRegisterClients(pContext, client, stuff) * range for extension replies. */ maxSets = PREDEFSETS + 2 * stuff->nRanges; - si = (SetInfoPtr)ALLOCATE_LOCAL(sizeof(SetInfoRec) * maxSets); + si = (SetInfoPtr)malloc(sizeof(SetInfoRec) * maxSets); if (!si) { err = BadAlloc; @@ -1970,7 +1970,7 @@ bailout: for (i = 0; i < maxSets; i++) if (si[i].intervals) free(si[i].intervals); - DEALLOCATE_LOCAL(si); + free(si); } if (pCanonClients && pCanonClients != (XID *)&stuff[1]) free(pCanonClients); @@ -2343,7 +2343,7 @@ ProcRecordGetContext(client) /* allocate and initialize space for record range info */ - pRangeInfo = (GetContextRangeInfoPtr)ALLOCATE_LOCAL( + pRangeInfo = (GetContextRangeInfoPtr)malloc( nRCAPs * sizeof(GetContextRangeInfoRec)); if (!pRangeInfo && nRCAPs > 0) return BadAlloc; @@ -2460,7 +2460,7 @@ bailout: { if (pRangeInfo[i].pRanges) free(pRangeInfo[i].pRanges); } - DEALLOCATE_LOCAL(pRangeInfo); + free(pRangeInfo); return err; } /* ProcRecordGetContext */ @@ -2882,14 +2882,14 @@ RecordConnectionSetupInfo(pContext, pci) if (pci->client->swapped) { - char * pConnSetup = (char *)ALLOCATE_LOCAL(prefixsize + restsize); + char * pConnSetup = (char *)malloc(prefixsize + restsize); if (!pConnSetup) return; SwapConnSetupPrefix(pci->prefix, pConnSetup); SwapConnSetupInfo(pci->setup, pConnSetup + prefixsize); RecordAProtocolElement(pContext, pci->client, XRecordClientStarted, (void *)pConnSetup, prefixsize + restsize, 0); - DEALLOCATE_LOCAL(pConnSetup); + free(pConnSetup); } else { diff --git a/nx-X11/programs/Xserver/record/set.c b/nx-X11/programs/Xserver/record/set.c index 1ea3fea4a..afb1024dd 100644 --- a/nx-X11/programs/Xserver/record/set.c +++ b/nx-X11/programs/Xserver/record/set.c @@ -71,9 +71,6 @@ typedef int Bool; typedef unsigned short CARD16; -#define ALLOCATE_LOCAL malloc -#define DEALLOCATE_LOCAL free - #ifndef max #define max(_a, _b) ( ((_a) > (_b)) ? (_a) : (_b) ) #endif @@ -358,7 +355,7 @@ IntervalListCreateSet(pIntervals, nIntervals, pMem, memsize) if (nIntervals > 0) { - stackIntervals = (RecordSetInterval *)ALLOCATE_LOCAL( + stackIntervals = (RecordSetInterval *)malloc( sizeof(RecordSetInterval) * nIntervals); if (!stackIntervals) return NULL; @@ -416,7 +413,7 @@ IntervalListCreateSet(pIntervals, nIntervals, pMem, memsize) memcpy(&prls[1], stackIntervals, nIntervals * sizeof(RecordSetInterval)); prls->nIntervals = nIntervals; bailout: - if (stackIntervals) DEALLOCATE_LOCAL(stackIntervals); + if (stackIntervals) free(stackIntervals); return (RecordSetPtr)prls; } -- cgit v1.2.3