From 76dde1f05ce835c10f1ed0423e95edf2f807056a Mon Sep 17 00:00:00 2001 From: meep-eep Date: Sat, 7 Dec 2002 20:06:39 +0000 Subject: [PATCH] Some fixes on the HMalloc patch. git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@373 8092fc87-c524-0410-9efc-e669fe64eaf9 --- sc2/src/sc2code/libs/graphics/sdl/rotozoom.c | 12 ++++++------ sc2/src/sc2code/libs/memory/w_memlib.c | 1 + sc2/src/sc2code/libs/misc.h | 2 -- .../sc2code/libs/sound/openal/decoders/decoder.c | 15 ++++++++------- .../openal/decoders/mikmod/mikmod_internals.h | 2 +- sc2/src/sc2code/libs/sound/openal/decoders/wav.c | 1 + sc2/src/starcon2.c | 3 +-- 7 files changed, 18 insertions(+), 18 deletions(-) diff --git a/sc2/src/sc2code/libs/graphics/sdl/rotozoom.c b/sc2/src/sc2code/libs/graphics/sdl/rotozoom.c index dde01ee2a..d1d5353b1 100644 --- a/sc2/src/sc2code/libs/graphics/sdl/rotozoom.c +++ b/sc2/src/sc2code/libs/graphics/sdl/rotozoom.c @@ -56,7 +56,7 @@ int zoomSurfaceRGBA(SDL_Surface * src, SDL_Surface * dst, int smooth) return (-1); } if ((say = (int *) HMalloc((dst->h + 1) * sizeof(Uint32))) == NULL) { - free(sax); + HFree(sax); return (-1); } @@ -198,8 +198,8 @@ int zoomSurfaceRGBA(SDL_Surface * src, SDL_Surface * dst, int smooth) /* * Remove temp arrays */ - free(sax); - free(say); + HFree(sax); + HFree(say); return (0); } @@ -232,7 +232,7 @@ int zoomSurfaceY(SDL_Surface * src, SDL_Surface * dst) } if ((say = (Uint32 *) HMalloc(dst->h * sizeof(Uint32))) == NULL) { if (sax != NULL) { - free(sax); + HFree(sax); } return (-1); } @@ -313,8 +313,8 @@ int zoomSurfaceY(SDL_Surface * src, SDL_Surface * dst) /* * Remove temp arrays */ - free(sax); - free(say); + HFree(sax); + HFree(say); return (0); } diff --git a/sc2/src/sc2code/libs/memory/w_memlib.c b/sc2/src/sc2code/libs/memory/w_memlib.c index e2b2c93c2..9e6cf158f 100644 --- a/sc2/src/sc2code/libs/memory/w_memlib.c +++ b/sc2/src/sc2code/libs/memory/w_memlib.c @@ -382,6 +382,7 @@ mem_init (void) { int i; + _MemorySem = CreateSemaphore (1); SetSemaphore (_MemorySem); freeListHead = &extents[0]; diff --git a/sc2/src/sc2code/libs/misc.h b/sc2/src/sc2code/libs/misc.h index ef4d114e5..90d9efda8 100644 --- a/sc2/src/sc2code/libs/misc.h +++ b/sc2/src/sc2code/libs/misc.h @@ -25,8 +25,6 @@ #define Stream FILE #define MEMTYPE_ANY 1 -extern Semaphore _MemorySem; - #define SqrtF16 sqrt #define Atan2F16 atan2 #define CosF16 cos diff --git a/sc2/src/sc2code/libs/sound/openal/decoders/decoder.c b/sc2/src/sc2code/libs/sound/openal/decoders/decoder.c index 67a5650de..6e49ca2af 100644 --- a/sc2/src/sc2code/libs/sound/openal/decoders/decoder.c +++ b/sc2/src/sc2code/libs/sound/openal/decoders/decoder.c @@ -29,6 +29,7 @@ #include #include #include +#include "libs/misc.h" #include "decoder.h" #include "wav.h" #include "libs/sound/sound_common.h" @@ -207,7 +208,7 @@ TFB_SoundDecoder* SoundDecoder_Load (char *filename, ALuint buffer_size) if ((vfp = fopen (filename, "r")) == NULL) { fprintf (stderr, "SoundDecoder_Load(): couldn't open %s\n", filename); - free (vf); + HFree (vf); return NULL; } @@ -220,7 +221,7 @@ TFB_SoundDecoder* SoundDecoder_Load (char *filename, ALuint buffer_size) { fprintf (stderr, "SoundDecoder_Load(): ov_open_callbacks failed for %s, error code %d\n", filename, rc); fclose (vfp); - free (vf); + HFree (vf); return NULL; } @@ -229,7 +230,7 @@ TFB_SoundDecoder* SoundDecoder_Load (char *filename, ALuint buffer_size) { fprintf (stderr, "SoundDecoder_Load(): failed to retrieve ogg bitstream info for %s\n", filename); ov_clear (vf); - free (vf); + HFree (vf); return NULL; } @@ -459,7 +460,7 @@ void SoundDecoder_Free (TFB_SoundDecoder *decoder) OggVorbis_File *vf = (OggVorbis_File *) decoder->data; //fprintf (stderr, "SoundDecoder_Free(): freeing %s\n", decoder->filename); ov_clear (vf); - free (vf); + HFree (vf); break; } default: @@ -469,9 +470,9 @@ void SoundDecoder_Free (TFB_SoundDecoder *decoder) } } - free (decoder->buffer); - free (decoder->filename); - free (decoder); + HFree (decoder->buffer); + HFree (decoder->filename); + HFree (decoder); } #endif diff --git a/sc2/src/sc2code/libs/sound/openal/decoders/mikmod/mikmod_internals.h b/sc2/src/sc2code/libs/sound/openal/decoders/mikmod/mikmod_internals.h index 4edee282c..d33d4f01c 100644 --- a/sc2/src/sc2code/libs/sound/openal/decoders/mikmod/mikmod_internals.h +++ b/sc2/src/sc2code/libs/sound/openal/decoders/mikmod/mikmod_internals.h @@ -47,7 +47,7 @@ static char *strdup(const char *str) { char *newstr; - newstr = (char *)HMalloc(strlen(str)+1); + newstr = (char *)malloc(strlen(str)+1); if ( newstr != NULL ) { strcpy(newstr, str); } diff --git a/sc2/src/sc2code/libs/sound/openal/decoders/wav.c b/sc2/src/sc2code/libs/sound/openal/decoders/wav.c index d8fc80534..0f11c5a6f 100644 --- a/sc2/src/sc2code/libs/sound/openal/decoders/wav.c +++ b/sc2/src/sc2code/libs/sound/openal/decoders/wav.c @@ -27,6 +27,7 @@ #include #include #include +#include "libs/misc.h" #include "wav.h" diff --git a/sc2/src/starcon2.c b/sc2/src/starcon2.c index 2495eff29..e466bf494 100644 --- a/sc2/src/starcon2.c +++ b/sc2/src/starcon2.c @@ -219,9 +219,8 @@ main (int argc, char *argv[]) InitTimeSystem (); InitTaskSystem (); - _MemorySem = CreateSemaphore (1); - GraphicsSem = CreateSemaphore (1); mem_init (); + GraphicsSem = CreateSemaphore (1); init_xform_control (); TFB_InitGraphics (gfxdriver, gfxflags, width, height, bpp);