diff --git a/sc2/src/sc2code/cleanup.c b/sc2/src/sc2code/cleanup.c index df2b60701..158dfd7a8 100644 --- a/sc2/src/sc2code/cleanup.c +++ b/sc2/src/sc2code/cleanup.c @@ -51,7 +51,7 @@ FreeKernel (void) UninitPlayerInput (); DestroyDrawable (ReleaseDrawable (Screen)); - DestroyContext (ReleaseContext (ScreenContext)); + DestroyContext (ScreenContext); UninitVideoPlayer (); UninitSound (); @@ -63,9 +63,9 @@ UninitContexts (void) { UninitQueue (&disp_q); - DestroyContext (ReleaseContext (OffScreenContext)); - DestroyContext (ReleaseContext (SpaceContext)); - DestroyContext (ReleaseContext (StatusContext)); + DestroyContext (OffScreenContext); + DestroyContext (SpaceContext); + DestroyContext (StatusContext); } static void diff --git a/sc2/src/sc2code/comm.c b/sc2/src/sc2code/comm.c index 84aacebb9..95529a2eb 100644 --- a/sc2/src/sc2code/comm.c +++ b/sc2/src/sc2code/comm.c @@ -1238,7 +1238,7 @@ DoCommunication (ENCOUNTER_STATE *pES) CommData.AlienTransitionDesc.AnimFlags &= ~(TALK_INTRO | TALK_DONE); SetContext (SpaceContext); - DestroyContext (ReleaseContext (TaskContext)); + DestroyContext (TaskContext); TaskContext = 0; UnlockMutex (GraphicsLock); @@ -1333,7 +1333,7 @@ HailAlien (void) SubtitleText.align = CommData.AlienTextAlign; // init subtitle cache context - TextCacheContext = CaptureContext (CreateContext ()); + TextCacheContext = CreateContext (); TextCacheFrame = CaptureDrawable ( CreateDrawable (WANT_PIXMAP, SIS_SCREEN_WIDTH, SIS_SCREEN_HEIGHT - SLIDER_Y - SLIDER_HEIGHT + 2, 1)); @@ -1354,7 +1354,7 @@ HailAlien (void) { RECT r; - TaskContext = CaptureContext (CreateContext ()); + TaskContext = CreateContext (); SetContext (TaskContext); SetContextFGFrame (Screen); GetFrameRect (CommData.AlienFrame, &r); @@ -1420,7 +1420,7 @@ HailAlien (void) DestroyFont (ReleaseFont (CommData.AlienFont)); DestroyDrawable (ReleaseDrawable (CommData.AlienFrame)); - DestroyContext (ReleaseContext (TextCacheContext)); + DestroyContext (TextCacheContext); DestroyDrawable (ReleaseDrawable (TextCacheFrame)); SetContext (SpaceContext); diff --git a/sc2/src/sc2code/credits.c b/sc2/src/sc2code/credits.c index af0987661..bf8c1b93a 100644 --- a/sc2/src/sc2code/credits.c +++ b/sc2/src/sc2code/credits.c @@ -314,8 +314,8 @@ credit_roll_task (void *data) TextBack = BUILD_COLOR (MAKE_RGB15 (0x00, 0x00, 0x00), 0x00); TextFore = BUILD_COLOR (MAKE_RGB15 (0x1F, 0x1F, 0x1F), 0x0F); - LocalContext = CaptureContext (CreateContext ()); - DrawContext = CaptureContext (CreateContext ()); + LocalContext = CreateContext (); + DrawContext = CreateContext (); total_h = disp_h = SCREEN_HEIGHT; @@ -530,8 +530,8 @@ credit_roll_task (void *data) } } - DestroyContext (ReleaseContext (DrawContext)); - DestroyContext (ReleaseContext (LocalContext)); + DestroyContext (DrawContext); + DestroyContext (LocalContext); // free remaining frames DestroyDrawable (ReleaseDrawable (Frame)); diff --git a/sc2/src/sc2code/displist.c b/sc2/src/sc2code/displist.c index 53f4be154..bdde70464 100644 --- a/sc2/src/sc2code/displist.c +++ b/sc2/src/sc2code/displist.c @@ -19,6 +19,10 @@ #include "displist.h" #include "libs/log.h" +#ifdef QUEUE_TABLE +#define NULL_HANDLE NULL +#endif + /* * This file contains code for generic doubly linked lists. * If QUEUE_TABLE is defined, each lists has its own preallocated @@ -40,7 +44,7 @@ InitQueue (QUEUE *pq, COUNT num_elements, OBJ_SIZE size) log_add (log_Debug, "InitQueue(): num_elements = %d (%d)", num_elements, (BYTE)num_elements); #endif - if (AllocQueueTab (pq, num_elements) && LockQueueTab (pq)) + if (AllocQueueTab (pq, num_elements) != NULL) { do FreeLink (pq, GetLinkAddr (pq, num_elements)); @@ -60,7 +64,6 @@ UninitQueue (QUEUE *pq) SetHeadLink (pq, NULL_HANDLE); SetTailLink (pq, NULL_HANDLE); SetFreeList (pq, NULL_HANDLE); - UnlockQueueTab (pq); FreeQueueTab (pq); return (TRUE); diff --git a/sc2/src/sc2code/displist.h b/sc2/src/sc2code/displist.h index 6db2a13e3..ef9b2c4b2 100644 --- a/sc2/src/sc2code/displist.h +++ b/sc2/src/sc2code/displist.h @@ -20,8 +20,9 @@ #define _DISPLIST_H #include -#include "libs/memlib.h" #include "port.h" +#include "compiler.h" +#include "misc.h" // Note that we MUST use the QUEUE_TABLE variant at this time, because // certain gameplay elements depend on it. Namely, the maximum number @@ -34,6 +35,7 @@ #ifdef QUEUE_TABLE typedef void* QUEUE_HANDLE; #else /* !QUEUE_TABLE */ +#include "libs/memlib.h" typedef MEM_HANDLE QUEUE_HANDLE; #endif /* QUEUE_TABLE */ @@ -55,7 +57,6 @@ typedef struct /* queue */ #ifdef QUEUE_TABLE BYTE *pq_tab; HLINK free_list; - MEM_HANDLE hq_tab; #endif COUNT object_size; #ifdef QUEUE_TABLE @@ -89,16 +90,13 @@ UnlockLink (const QUEUE *pq, HLINK h) #define GetFreeList(pq) (pq)->free_list #define SetFreeList(pq, h) (pq)->free_list = (h) #define AllocQueueTab(pq,n) \ - ((pq)->hq_tab = mem_allocate ((MEM_SIZE)((COUNT)(pq)->object_size * \ - (COUNT)((pq)->num_objects = (BYTE)(n))), \ - MEM_PRIMARY)) -#define LockQueueTab(pq) ((pq)->pq_tab = (BYTE*)mem_lock ((pq)->hq_tab)) -#define UnlockQueueTab(pq) mem_unlock ((pq)->hq_tab) -#define FreeQueueTab(pq) mem_release ((pq)->hq_tab); (pq)->hq_tab = 0 + ((pq)->pq_tab = HMalloc (((COUNT)(pq)->object_size * \ + (COUNT)((pq)->num_objects = (BYTE)(n))))) +#define FreeQueueTab(pq) HFree ((pq)->pq_tab); (pq)->pq_tab = NULL #define SizeQueueTab(pq) (COUNT)((pq)->num_objects) #define GetLinkAddr(pq,i) (HLINK)((pq)->pq_tab + ((pq)->object_size * ((i) - 1))) #else /* !QUEUE_TABLE */ -#define AllocLink(pq) (HLINK)mem_request ((pq)->object_size) +#define AllocLink(pq) (HLINK)mem_allocate ((pq)->object_size, DEFAULT_MEM_FLAGS) #define LockLink(pq, h) (LINK*)mem_lock (h) #define UnlockLink(pq, h) mem_unlock (h) #define FreeLink(pq,h) mem_release (h) diff --git a/sc2/src/sc2code/dummy.c b/sc2/src/sc2code/dummy.c index 3e686df0d..59c7861d4 100644 --- a/sc2/src/sc2code/dummy.c +++ b/sc2/src/sc2code/dummy.c @@ -84,7 +84,7 @@ enum MEM_HANDLE hData; which_res = GetResFileChar (fp); - hData = mem_request (sizeof (CODERES_STRUCT)); + hData = mem_allocate (sizeof (CODERES_STRUCT), DEFAULT_MEM_FLAGS); if (hData) { RACE_DESC *RDPtr; @@ -373,15 +373,4 @@ ReleaseCodeRes (void *CodeRef) } return (0); -} - -DRAWABLE -CreatePixmapRegion (FRAME Frame, POINT *lpOrg, SIZE width, SIZE height) -{ - (void) lpOrg; /* Satisfying compiler (unused parameter) */ - (void) width; /* Satisfying compiler (unused parameter) */ - (void) height; /* Satisfying compiler (unused parameter) */ - return (GetFrameHandle (Frame)); -} - - +} \ No newline at end of file diff --git a/sc2/src/sc2code/globdata.c b/sc2/src/sc2code/globdata.c index ebed72220..0721e123a 100644 --- a/sc2/src/sc2code/globdata.c +++ b/sc2/src/sc2code/globdata.c @@ -125,7 +125,7 @@ CreateRadar (void) RECT r; CONTEXT OldContext; - RadarContext = CaptureContext (CreateContext ()); + RadarContext = CreateContext (); OldContext = SetContext (RadarContext); SetContextFGFrame (Screen); r.corner.x = RADAR_X; @@ -372,7 +372,7 @@ InitSIS (void) void FreeSC2Data (void) { - DestroyContext (ReleaseContext (RadarContext)); + DestroyContext (RadarContext); RadarContext = 0; DestroyDrawable (ReleaseDrawable (FontGradFrame)); FontGradFrame = 0; diff --git a/sc2/src/sc2code/libs/decomp/lzdecode.c b/sc2/src/sc2code/libs/decomp/lzdecode.c index fa519d37a..82aaab1bb 100644 --- a/sc2/src/sc2code/libs/decomp/lzdecode.c +++ b/sc2/src/sc2code/libs/decomp/lzdecode.c @@ -29,6 +29,7 @@ #include #include #include "libs/decomp/lzh.h" +#include "reslib.h" PLZHCODE_DESC _lpCurCodeDesc; STREAM_TYPE _StreamType; @@ -103,7 +104,6 @@ StartHuff (void) DECODE_REF copen (void *InStream, STREAM_TYPE SType, STREAM_MODE SMode) { - MEM_HANDLE h; DWORD StreamLength; _StreamType = SType; @@ -132,17 +132,14 @@ copen (void *InStream, STREAM_TYPE SType, STREAM_MODE SMode) StreamLength = MAKE_DWORD (loword, hiword); } - h = 0; if (StreamLength == 0xFFFFFFFF - || (h = AllocCodeDesc ()) == 0 - || (_lpCurCodeDesc = LockCodeDesc (h)) == 0) + || (_lpCurCodeDesc = AllocCodeDesc ()) == NULL) { - _lpCurCodeDesc = 0; - FreeCodeDesc (h); + FreeCodeDesc (_lpCurCodeDesc); + _lpCurCodeDesc = NULL; } else { - _lpCurCodeDesc->fh = h; _lpCurCodeDesc->Stream = _Stream; _lpCurCodeDesc->StreamType = _StreamType; _lpCurCodeDesc->StreamMode = SMode; @@ -168,8 +165,8 @@ cclose (PLZHCODE_DESC lpCodeDesc) (*_lpCurCodeDesc->CleanupFunc) (); StreamIndex = lpCodeDesc->StreamIndex; - UnlockCodeDesc (lpCodeDesc->fh); - FreeCodeDesc (lpCodeDesc->fh); + FreeCodeDesc (lpCodeDesc); + _lpCurCodeDesc = NULL; return (StreamIndex); } diff --git a/sc2/src/sc2code/libs/decomp/lzencode.c b/sc2/src/sc2code/libs/decomp/lzencode.c index a754e05db..fa0f9d0cd 100644 --- a/sc2/src/sc2code/libs/decomp/lzencode.c +++ b/sc2/src/sc2code/libs/decomp/lzencode.c @@ -26,38 +26,34 @@ #include #include "lzh.h" +#include "reslib.h" static UWORD match_position, match_length; static SWORD *lson; static SWORD *rson; static SWORD *dad; +static SWORD *encode_arrays; #define AllocEncodeArrays() \ - mem_allocate ( \ + HCalloc ( \ (MEM_SIZE)(((N + 1) + (N + 257) + (N + 1)) \ - * sizeof (lson[0]) + sizeof (MEM_HANDLE)), \ - MEM_ZEROINIT) -#define LockCodeArrays (SWORD*)mem_lock -#define UnlockCodeArrays mem_unlock -#define FreeCodeArrays mem_release + * sizeof (lson[0]))) +#define FreeCodeArrays HFree static BOOLEAN InitTree (void) { - MEM_HANDLE h; - - if ((h = AllocEncodeArrays ()) == 0 - || (lson = LockCodeArrays (h)) == 0) + if ((encode_arrays = AllocEncodeArrays ()) == NULL) { - FreeCodeArrays (h); + FreeCodeArrays (encode_arrays); + encode_arrays = NULL; return (FALSE); } else { SWORD i; - *(MEM_HANDLE *)lson = h; - lson = (SWORD*)((BYTE*)lson + sizeof (h)); + lson = encode_arrays; rson = lson + (N + 1); dad = rson + (N + 257); @@ -277,18 +273,17 @@ EncodePosition (UWORD c) static void UninitTree (void) { - MEM_HANDLE h; - if (_workbuflen) { OutChar ((BYTE)(_workbuf >> 8)); ++_lpCurCodeDesc->StreamIndex; } - lson = (SWORD*)((BYTE*)lson - sizeof (h)); - h = *(MEM_HANDLE *)lson; - UnlockCodeArrays (h); - FreeCodeArrays (h); + FreeCodeArrays (encode_arrays); + encode_arrays = NULL; + lson = NULL; + rson = NULL; + dad = NULL; } static void diff --git a/sc2/src/sc2code/libs/decomp/lzh.h b/sc2/src/sc2code/libs/decomp/lzh.h index 9fe8245dc..2423569ef 100644 --- a/sc2/src/sc2code/libs/decomp/lzh.h +++ b/sc2/src/sc2code/libs/decomp/lzh.h @@ -19,8 +19,8 @@ #ifndef _LZH_H #define _LZH_H -#include "reslib.h" #include "declib.h" +#include "misc.h" /* LZSS Parameters */ @@ -41,8 +41,6 @@ struct _LZHCODE_DESC { - MEM_HANDLE fh; - COUNT buf_index, restart_index, bytes_left; BYTE text_buf[N + F - 1]; /* reconstruct freq tree */ @@ -77,11 +75,8 @@ typedef LZHCODE_DESC *PLZHCODE_DESC; (*_Stream++ = (BYTE)(c))) -#define AllocCodeDesc() \ - mem_allocate ((MEM_SIZE)sizeof (LZHCODE_DESC), MEM_ZEROINIT) -#define LockCodeDesc (PLZHCODE_DESC)mem_lock -#define UnlockCodeDesc mem_unlock -#define FreeCodeDesc mem_release +#define AllocCodeDesc() HCalloc ((MEM_SIZE)sizeof (LZHCODE_DESC)) +#define FreeCodeDesc HFree extern void _update (COUNT c); extern void StartHuff (void); diff --git a/sc2/src/sc2code/libs/gfxlib.h b/sc2/src/sc2code/libs/gfxlib.h index 6ac45e9cc..e307b3590 100644 --- a/sc2/src/sc2code/libs/gfxlib.h +++ b/sc2/src/sc2code/libs/gfxlib.h @@ -131,8 +131,6 @@ typedef struct STAMP IntersectStamp; } INTERSECT_CONTROL; -typedef MEM_HANDLE CONTEXT_REF; - typedef DWORD DRAWABLE; #define BUILD_DRAWABLE(h,i) ((DRAWABLE)MAKE_DWORD(h,i)) @@ -172,8 +170,6 @@ extern BOOLEAN InitGraphics (int argc, char *argv[], COUNT extern void UninitGraphics (void); extern CONTEXT SetContext (CONTEXT Context); -extern CONTEXT CaptureContext (CONTEXT_REF ContextRef); -extern CONTEXT_REF ReleaseContext (CONTEXT Context); extern COLOR SetContextForeGroundColor (COLOR Color); extern COLOR SetContextBackGroundColor (COLOR Color); extern FRAME SetContextFGFrame (FRAME Frame); @@ -196,8 +192,8 @@ extern void UnbatchGraphics (void); extern void FlushGraphics (void); extern void ClearBackGround (RECT *pClipRect); extern void ClearDrawable (void); -extern CONTEXT_REF CreateContext (void); -extern BOOLEAN DestroyContext (CONTEXT_REF ContextRef); +extern CONTEXT CreateContext (void); +extern BOOLEAN DestroyContext (CONTEXT ContextRef); extern DRAWABLE CreateDisplay (CREATE_FLAGS CreateFlags, SIZE *pwidth, SIZE *pheight); extern DRAWABLE CreateDrawable (CREATE_FLAGS CreateFlags, SIZE width, diff --git a/sc2/src/sc2code/libs/graphics/context.c b/sc2/src/sc2code/libs/graphics/context.c index 7723ba35f..63c76bca7 100644 --- a/sc2/src/sc2code/libs/graphics/context.c +++ b/sc2/src/sc2code/libs/graphics/context.c @@ -65,67 +65,40 @@ SetContext (CONTEXT Context) return (LastContext); } -CONTEXT_REF +CONTEXT CreateContext (void) { - CONTEXT_REF ContextRef; + CONTEXT NewContext; - ContextRef = AllocContext (); - if (ContextRef) + NewContext = AllocContext (); + if (NewContext) { CONTEXT OldContext; /* initialize context */ - OldContext = SetContext (CaptureContext (ContextRef)); + OldContext = SetContext (NewContext); SetContextForeGroundColor ( BUILD_COLOR (MAKE_RGB15 (0x1F, 0x1F, 0x1F), 0x0F)); SetContextBackGroundColor ( BUILD_COLOR (MAKE_RGB15 (0x00, 0x00, 0x00), 0x00)); SetContextClipping (TRUE); - ReleaseContext (SetContext (OldContext)); + SetContext (OldContext); } - return (ContextRef); + return (NewContext); } BOOLEAN -DestroyContext (CONTEXT_REF ContextRef) +DestroyContext (CONTEXT ContextRef) { if (ContextRef == 0) return (FALSE); - if (_pCurContext && _pCurContext->ContextRef == ContextRef) + if (_pCurContext && _pCurContext == ContextRef) SetContext ((CONTEXT)0); - return (FreeContext (ContextRef)); -} - -CONTEXT -CaptureContext (CONTEXT_REF ContextRef) -{ - CONTEXT ContextPtr; - - ContextPtr = LockContext (ContextRef); - if (ContextPtr) - ContextPtr->ContextRef = ContextRef; - - return (ContextPtr); -} - -CONTEXT_REF -ReleaseContext (CONTEXT ContextPtr) -{ - if (ContextPtr) - { - CONTEXT_REF ContextRef; - - ContextRef = ContextPtr->ContextRef; - UnlockContext (ContextRef); - - return (ContextRef); - } - - return (0); + FreeContext (ContextRef); + return TRUE; } COLOR diff --git a/sc2/src/sc2code/libs/graphics/context.h b/sc2/src/sc2code/libs/graphics/context.h index d6e987242..8e6a86377 100644 --- a/sc2/src/sc2code/libs/graphics/context.h +++ b/sc2/src/sc2code/libs/graphics/context.h @@ -27,7 +27,6 @@ typedef UWORD FBK_FLAGS; struct context_desc { - CONTEXT_REF ContextRef; UWORD Flags; COLOR ForeGroundColor, BackGroundColor; @@ -42,14 +41,8 @@ struct context_desc }; -#define CONTEXT_PRIORITY DEFAULT_MEM_PRIORITY - -#define AllocContext() \ - (CONTEXT_REF)mem_allocate ((MEM_SIZE)sizeof (CONTEXT_DESC), \ - MEM_ZEROINIT | MEM_PRIMARY) -#define LockContext (CONTEXT)mem_lock -#define UnlockContext mem_unlock -#define FreeContext mem_release +#define AllocContext() HCalloc ((MEM_SIZE)sizeof (CONTEXT_DESC)) +#define FreeContext HFree extern CONTEXT _pCurContext; extern PRIMITIVE _locPrim; diff --git a/sc2/src/sc2code/libs/memlib.h b/sc2/src/sc2code/libs/memlib.h index bffeb6aeb..00868d27d 100644 --- a/sc2/src/sc2code/libs/memlib.h +++ b/sc2/src/sc2code/libs/memlib.h @@ -44,21 +44,12 @@ typedef struct mem_header { #define GET_MEM_HEADER(addr) ((MEM_HEADER *) \ (((char *) addr) - sizeof (MEM_HEADER))) -//Newer verion from w_memlib.c to follow... -/* -extern MEM_BOOL mem_init (MEM_SIZE core_size, PMEM_SIZE pmin_addressable, - PSTR disk_name);*/ - extern BOOLEAN mem_init (void); - extern BOOLEAN mem_uninit (void); extern MEM_HANDLE mem_allocate (MEM_SIZE size, MEM_FLAGS flags); extern BOOLEAN mem_release (MEM_HANDLE handle); -#define mem_request(size) \ - mem_allocate((MEM_SIZE)(size), DEFAULT_MEM_FLAGS) - extern void* mem_lock (MEM_HANDLE handle); extern BOOLEAN mem_unlock (MEM_HANDLE handle); diff --git a/sc2/src/sc2code/planets/genchmmr.c b/sc2/src/sc2code/planets/genchmmr.c index d58526e1a..f0b477c9d 100644 --- a/sc2/src/sc2code/planets/genchmmr.c +++ b/sc2/src/sc2code/planets/genchmmr.c @@ -113,7 +113,7 @@ GenerateChmmr (BYTE control) CaptureStringTable ( LoadStringTable (CHMMR_BASE_STRTAB)); - ScanContext = CaptureContext (CreateContext ()); + ScanContext = CreateContext (); SetContext (ScanContext); SetContextFGFrame (Screen); r.corner.x = (SIS_ORG_X + SIS_SCREEN_WIDTH) - MAP_WIDTH; @@ -125,7 +125,7 @@ GenerateChmmr (BYTE control) DoDiscoveryReport (MenuSounds); SetContext (SpaceContext); - DestroyContext (ReleaseContext (ScanContext)); + DestroyContext (ScanContext); ScanContext = 0; DestroyStringTable (ReleaseStringTable ( diff --git a/sc2/src/sc2code/planets/planets.c b/sc2/src/sc2code/planets/planets.c index d911698d0..eeff8d76f 100644 --- a/sc2/src/sc2code/planets/planets.c +++ b/sc2/src/sc2code/planets/planets.c @@ -152,7 +152,7 @@ LoadPlanet (FRAME SurfDefFrame) StopMusic (); - TaskContext = CaptureContext (CreateContext ()); + TaskContext = CreateContext (); pPlanetDesc = pSolarSysState->pOrbitalDesc; @@ -263,7 +263,7 @@ FreePlanet (void) Orbit->ScratchArray = 0; } - DestroyContext (ReleaseContext (TaskContext)); + DestroyContext (TaskContext); TaskContext = 0; DestroyStringTable (ReleaseStringTable ( diff --git a/sc2/src/sc2code/planets/scan.c b/sc2/src/sc2code/planets/scan.c index 068849c8b..4462e6096 100644 --- a/sc2/src/sc2code/planets/scan.c +++ b/sc2/src/sc2code/planets/scan.c @@ -1229,7 +1229,7 @@ ScanSystem (void) (MAP_HEIGHT >> 1) << MAG_SHIFT; LockMutex (GraphicsLock); - ScanContext = CaptureContext (CreateContext ()); + ScanContext = CreateContext (); SetContext (ScanContext); MenuState.flash_rect0.extent.width = FLASH_WIDTH; MenuState.flash_rect0.extent.height = FLASH_HEIGHT; @@ -1263,7 +1263,7 @@ ScanSystem (void) LockMutex (GraphicsLock); SetContext (SpaceContext); DestroyDrawable (ReleaseDrawable (MenuState.flash_frame0)); - DestroyContext (ReleaseContext (ScanContext)); + DestroyContext (ScanContext); ScanContext = 0; UnlockMutex (GraphicsLock); } diff --git a/sc2/src/sc2code/save.c b/sc2/src/sc2code/save.c index 53b78d8ea..604e74f8c 100644 --- a/sc2/src/sc2code/save.c +++ b/sc2/src/sc2code/save.c @@ -618,24 +618,21 @@ BOOLEAN SaveGame (COUNT which_game, SUMMARY_DESC *SummPtr) { BOOLEAN success, made_room; - void *out_fp; - MEM_HANDLE h; + void *out_fp, *h; DECODE_REF fh; success = TRUE; made_room = FALSE; RetrySave: - h = mem_request (10 * 1024); - out_fp = mem_lock (h); - if (out_fp == 0 - || (fh = copen (out_fp, MEMORY_STREAM, STREAM_WRITE)) == 0) + h = HMalloc (10 * 1024); + if (h == 0 + || (fh = copen (h, MEMORY_STREAM, STREAM_WRITE)) == 0) { if (success) { success = FALSE; made_room = TRUE; - mem_unlock (h); - mem_release (h); + HFree (h); FreeSC2Data (); log_add (log_Debug, "Insufficient room for save buffers" @@ -821,11 +818,10 @@ RetrySave: success = SaveSummary (SummPtr, out_fp); // Then write the rest of the data. - if (success && WriteResFile (mem_lock (h), (COUNT)flen, 1, + if (success && WriteResFile (h, (COUNT)flen, 1, out_fp) == 0) success = FALSE; - mem_unlock (h); if (res_CloseResFile ((uio_Stream *)out_fp) == 0) success = FALSE; @@ -837,8 +833,7 @@ RetrySave: DeleteResFile (saveDir, file); } - mem_unlock (h); - mem_release (h); + HFree (h); if (made_room) LoadSC2Data (); diff --git a/sc2/src/sc2code/setup.c b/sc2/src/sc2code/setup.c index 02769bc4c..41c165704 100644 --- a/sc2/src/sc2code/setup.c +++ b/sc2/src/sc2code/setup.c @@ -98,7 +98,7 @@ LoadKernel (int argc, char *argv[]) InitSound (argc, argv); InitVideoPlayer (TRUE); - ScreenContext = CaptureContext (CreateContext ()); + ScreenContext = CreateContext (); if (ScreenContext == NULL) return FALSE; @@ -150,7 +150,7 @@ InitContexts (void) { RECT r; - StatusContext = CaptureContext (CreateContext ()); + StatusContext = CreateContext (); if (StatusContext == NULL) return FALSE; @@ -162,11 +162,11 @@ InitContexts (void) r.extent.height = STATUS_HEIGHT; SetContextClipRect (&r); - SpaceContext = CaptureContext (CreateContext ()); + SpaceContext = CreateContext (); if (SpaceContext == NULL) return FALSE; - OffScreenContext = CaptureContext (CreateContext ()); + OffScreenContext = CreateContext (); if (OffScreenContext == NULL) return FALSE;