From 09ef99919c010801bd4220d482a867035b6f4f25 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/hw/nxagent/NXdamage.c | 4 ++-- nx-X11/programs/Xserver/hw/nxagent/NXdispatch.c | 8 ++++---- nx-X11/programs/Xserver/hw/nxagent/NXdixfonts.c | 8 ++++---- nx-X11/programs/Xserver/hw/nxagent/NXextension.c | 4 ++-- nx-X11/programs/Xserver/hw/nxagent/NXmiexpose.c | 6 +++--- nx-X11/programs/Xserver/hw/nxagent/NXrender.c | 12 ++++++------ 6 files changed, 21 insertions(+), 21 deletions(-) (limited to 'nx-X11/programs/Xserver/hw/nxagent') diff --git a/nx-X11/programs/Xserver/hw/nxagent/NXdamage.c b/nx-X11/programs/Xserver/hw/nxagent/NXdamage.c index e6f251a51..ad02e13a8 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/NXdamage.c +++ b/nx-X11/programs/Xserver/hw/nxagent/NXdamage.c @@ -112,7 +112,7 @@ damageText (DrawablePtr pDrawable, imageblt = (textType == TT_IMAGE8) || (textType == TT_IMAGE16); - charinfo = (CharInfoPtr *) ALLOCATE_LOCAL(count * sizeof(CharInfoPtr)); + charinfo = (CharInfoPtr *) malloc(count * sizeof(CharInfoPtr)); if (!charinfo) return x; @@ -139,7 +139,7 @@ damageText (DrawablePtr pDrawable, #endif } - DEALLOCATE_LOCAL(charinfo); + free(charinfo); return x + w; } diff --git a/nx-X11/programs/Xserver/hw/nxagent/NXdispatch.c b/nx-X11/programs/Xserver/hw/nxagent/NXdispatch.c index a46434bf1..652d54479 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/NXdispatch.c +++ b/nx-X11/programs/Xserver/hw/nxagent/NXdispatch.c @@ -274,7 +274,7 @@ Dispatch(void) #endif - clientReady = (int *) ALLOCATE_LOCAL(sizeof(int) * MaxClients); + clientReady = (int *) malloc(sizeof(int) * MaxClients); if (!clientReady) return; @@ -571,7 +571,7 @@ Reply Total Cached Bits In Bits Out Bits/Reply Ratio saveAgentState("TERMINATED"); KillAllClients(); - DEALLOCATE_LOCAL(clientReady); + free(clientReady); dispatchException &= ~DE_RESET; } @@ -653,7 +653,7 @@ ProcQueryTree(register ClientPtr client) { int curChild = 0; - childIDs = (Window *) ALLOCATE_LOCAL(numChildren * sizeof(Window)); + childIDs = (Window *) malloc(numChildren * sizeof(Window)); if (!childIDs) return BadAlloc; for (pChild = pWin->lastChild; pChild != pHead; pChild = pChild->prevSib) @@ -673,7 +673,7 @@ ProcQueryTree(register ClientPtr client) { client->pSwapReplyFunc = (ReplySwapPtr) Swap32Write; WriteSwappedDataToClient(client, numChildren * sizeof(Window), childIDs); - DEALLOCATE_LOCAL(childIDs); + free(childIDs); } return(client->noClientException); diff --git a/nx-X11/programs/Xserver/hw/nxagent/NXdixfonts.c b/nx-X11/programs/Xserver/hw/nxagent/NXdixfonts.c index b3d7cc9d7..1b7ce114b 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/NXdixfonts.c +++ b/nx-X11/programs/Xserver/hw/nxagent/NXdixfonts.c @@ -564,7 +564,7 @@ finish: reply.nFonts = nnames; reply.sequenceNumber = client->sequence; - bufptr = bufferStart = (char *) ALLOCATE_LOCAL(reply.length << 2); + bufptr = bufferStart = (char *) malloc(reply.length << 2); if (!bufptr && reply.length) { SendErrorToClient(client, X_ListFonts, 0, 0, BadAlloc); @@ -607,7 +607,7 @@ finish: client->pSwapReplyFunc = ReplySwapVector[X_ListFonts]; WriteSwappedDataToClient(client, sizeof(xListFontsReply), &reply); WriteToClient(client, stringLens + nnames, bufferStart); - DEALLOCATE_LOCAL(bufferStart); + free(bufferStart); bail: if (c->slept) @@ -968,7 +968,7 @@ SetDefaultFontPath(char *path) /* get enough for string, plus values -- use up commas */ len = strlen(temp_path) + 1; - nump = cp = newpath = (unsigned char *) ALLOCATE_LOCAL(len); + nump = cp = newpath = (unsigned char *) malloc(len); if (!newpath) { free(temp_path); return BadAlloc; @@ -991,7 +991,7 @@ SetDefaultFontPath(char *path) err = SetFontPathElements(num, newpath, &bad, TRUE); - DEALLOCATE_LOCAL(newpath); + free(newpath); free(temp_path); return err; diff --git a/nx-X11/programs/Xserver/hw/nxagent/NXextension.c b/nx-X11/programs/Xserver/hw/nxagent/NXextension.c index f6c63e699..9ec6be8ef 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/NXextension.c +++ b/nx-X11/programs/Xserver/hw/nxagent/NXextension.c @@ -163,7 +163,7 @@ ProcListExtensions(ClientPtr client) total_length += strlen(extensions[i]->aliases[j]) + 1; } reply.length = (total_length + 3) >> 2; - buffer = bufptr = (char *)ALLOCATE_LOCAL(total_length); + buffer = bufptr = (char *)malloc(total_length); if (!buffer) return(BadAlloc); for (i=0; inoClientException); } diff --git a/nx-X11/programs/Xserver/hw/nxagent/NXmiexpose.c b/nx-X11/programs/Xserver/hw/nxagent/NXmiexpose.c index eb92dd3bb..bcb88d42d 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/NXmiexpose.c +++ b/nx-X11/programs/Xserver/hw/nxagent/NXmiexpose.c @@ -566,7 +566,7 @@ int what; } } - prect = (xRectangle *)ALLOCATE_LOCAL(RegionNumRects(prgn) * + prect = (xRectangle *)malloc(RegionNumRects(prgn) * sizeof(xRectangle)); if (!prect) return; @@ -591,7 +591,7 @@ int what; pGC = GetScratchGC(pWin->drawable.depth, pWin->drawable.pScreen); if (!pGC) { - DEALLOCATE_LOCAL(prect); + free(prect); return; } /* @@ -723,7 +723,7 @@ int what; } prect -= numRects; (*pGC->ops->PolyFillRect)((DrawablePtr)pWin, pGC, numRects, prect); - DEALLOCATE_LOCAL(prect); + free(prect); if (pWin->backStorage) (*pWin->drawable.pScreen->DrawGuarantee) (pWin, pGC, GuaranteeNothing); diff --git a/nx-X11/programs/Xserver/hw/nxagent/NXrender.c b/nx-X11/programs/Xserver/hw/nxagent/NXrender.c index 25e162445..ef288db0b 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/NXrender.c +++ b/nx-X11/programs/Xserver/hw/nxagent/NXrender.c @@ -987,7 +987,7 @@ ProcRenderCompositeGlyphs (ClientPtr client) glyphsBase = glyphsLocal; else { - glyphsBase = (GlyphPtr *) ALLOCATE_LOCAL (nglyph * sizeof (GlyphPtr)); + glyphsBase = (GlyphPtr *) malloc (nglyph * sizeof (GlyphPtr)); if (!glyphsBase) return BadAlloc; } @@ -995,7 +995,7 @@ ProcRenderCompositeGlyphs (ClientPtr client) listsBase = listsLocal; else { - listsBase = (GlyphListPtr) ALLOCATE_LOCAL (nlist * sizeof (GlyphListRec)); + listsBase = (GlyphListPtr) malloc (nlist * sizeof (GlyphListRec)); if (!listsBase) return BadAlloc; } @@ -1031,9 +1031,9 @@ ProcRenderCompositeGlyphs (ClientPtr client) { client->errorValue = gs; if (glyphsBase != glyphsLocal) - DEALLOCATE_LOCAL (glyphsBase); + free (glyphsBase); if (listsBase != listsLocal) - DEALLOCATE_LOCAL (listsBase); + free (listsBase); return RenderErrBase + BadGlyphSet; } } @@ -1140,9 +1140,9 @@ ProcRenderCompositeGlyphs (ClientPtr client) nxagentGlyphsExtents = NullBox; if (glyphsBase != glyphsLocal) - DEALLOCATE_LOCAL (glyphsBase); + free (glyphsBase); if (listsBase != listsLocal) - DEALLOCATE_LOCAL (listsBase); + free (listsBase); free(elementsBase); -- cgit v1.2.3