mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-11-10 23:02:03 +00:00
Replace remaining instances of regular malloc/calloc/realloc/strdup with our memory error handler versions
git-svn-id: https://svn.eduke32.com/eduke32@7079 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
9613bbac33
commit
1f8b23152e
21 changed files with 77 additions and 74 deletions
|
@ -562,21 +562,21 @@ int32_t MV_PlayFLAC(char *ptr, uint32_t ptrlength, int32_t loopstart, int32_t lo
|
|||
{
|
||||
char const * const tag = loopStartTags[t];
|
||||
if (field == strlen(tag) && Bstrncasecmp(entry, tag, field) == 0)
|
||||
vc_loopstart = strdup(value);
|
||||
vc_loopstart = Xstrdup(value);
|
||||
}
|
||||
|
||||
for (size_t t = 0; t < loopEndTagCount && vc_loopend == NULL; ++t)
|
||||
{
|
||||
char const * const tag = loopEndTags[t];
|
||||
if (field == strlen(tag) && Bstrncasecmp(entry, tag, field) == 0)
|
||||
vc_loopend = strdup(value);
|
||||
vc_loopend = Xstrdup(value);
|
||||
}
|
||||
|
||||
for (size_t t = 0; t < loopLengthTagCount && vc_looplength == NULL; ++t)
|
||||
{
|
||||
char const * const tag = loopLengthTags[t];
|
||||
if (field == strlen(tag) && Bstrncasecmp(entry, tag, field) == 0)
|
||||
vc_looplength = strdup(value);
|
||||
vc_looplength = Xstrdup(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ extern "C" {
|
|||
#endif
|
||||
|
||||
|
||||
#define NewNode(type) ((type *)Bmalloc(sizeof(type)))
|
||||
#define NewNode(type) ((type *)Xmalloc(sizeof(type)))
|
||||
|
||||
|
||||
#define LL_New(rootnode, type, next, prev) \
|
||||
|
|
|
@ -119,7 +119,7 @@ int32_t MV_PlayXMP(char *ptr, uint32_t ptrlength, int32_t loopstart, int32_t loo
|
|||
return MV_Error;
|
||||
}
|
||||
|
||||
xmpd = (xmp_data *)calloc(1, sizeof(xmp_data));
|
||||
xmpd = (xmp_data *)Xcalloc(1, sizeof(xmp_data));
|
||||
if (!xmpd)
|
||||
{
|
||||
MV_SetErrorCode(MV_InvalidFile);
|
||||
|
|
|
@ -98,7 +98,7 @@ int32_t animvpx_init_codec(const animvpx_ivf_header_t *info, int32_t inhandle, a
|
|||
|
||||
//
|
||||
codec->inhandle = inhandle;
|
||||
codec->pic = (uint8_t *)Bcalloc(info->width*info->height,4);
|
||||
codec->pic = (uint8_t *)Xcalloc(info->width*info->height,4);
|
||||
|
||||
codec->compbuflen = codec->compbufallocsiz = 0;
|
||||
codec->compbuf = NULL;
|
||||
|
@ -168,14 +168,14 @@ static int32_t animvpx_read_frame(int32_t inhandle, uint8_t **bufptr, uint32_t *
|
|||
|
||||
if (!*bufptr)
|
||||
{
|
||||
*bufptr = (uint8_t *)Bmalloc(hdr.framesiz);
|
||||
*bufptr = (uint8_t *)Xmalloc(hdr.framesiz);
|
||||
if (!*bufptr)
|
||||
return 2;
|
||||
*bufallocsizptr = hdr.framesiz;
|
||||
}
|
||||
else if (*bufallocsizptr < hdr.framesiz)
|
||||
{
|
||||
*bufptr = (uint8_t *)Brealloc(*bufptr, hdr.framesiz);
|
||||
*bufptr = (uint8_t *)Xrealloc(*bufptr, hdr.framesiz);
|
||||
if (!*bufptr)
|
||||
return 2;
|
||||
*bufallocsizptr = hdr.framesiz;
|
||||
|
|
|
@ -99,7 +99,7 @@ char *Bgethomedir(void)
|
|||
{
|
||||
if (loaded)
|
||||
FreeLibrary(hShell32);
|
||||
return Bstrdup(appdata);
|
||||
return Xstrdup(appdata);
|
||||
}
|
||||
|
||||
if (loaded)
|
||||
|
@ -114,11 +114,11 @@ char *Bgethomedir(void)
|
|||
drv = strchr(cwd, ':');
|
||||
if (drv)
|
||||
drv[1] = '\0';
|
||||
return Bstrdup(cwd);
|
||||
return Xstrdup(cwd);
|
||||
#else
|
||||
char *e = getenv("HOME");
|
||||
if (!e) return NULL;
|
||||
return Bstrdup(e);
|
||||
return Xstrdup(e);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -133,7 +133,7 @@ char *Bgetappdir(void)
|
|||
// trim off the filename
|
||||
char *slash = Bstrrchr(appdir, '\\');
|
||||
if (slash) slash[0] = 0;
|
||||
dir = Bstrdup(appdir);
|
||||
dir = Xstrdup(appdir);
|
||||
}
|
||||
|
||||
#elif defined EDUKE32_OSX
|
||||
|
@ -148,7 +148,7 @@ char *Bgetappdir(void)
|
|||
if(ret == 0 && buf[0] != '\0') {
|
||||
// again, remove executable name with dirname()
|
||||
// on FreeBSD dirname() seems to use some internal buffer
|
||||
dir = strdup(dirname(buf));
|
||||
dir = Xstrdup(dirname(buf));
|
||||
}
|
||||
#elif defined __linux || defined EDUKE32_BSD
|
||||
char buf[PATH_MAX] = {0};
|
||||
|
@ -163,7 +163,7 @@ char *Bgetappdir(void)
|
|||
// remove executable name with dirname(3)
|
||||
// on Linux, dirname() will modify buf2 (cutting off executable name) and return it
|
||||
// on FreeBSD it seems to use some internal buffer instead.. anyway, just strdup()
|
||||
dir = Bstrdup(dirname(buf2));
|
||||
dir = Xstrdup(dirname(buf2));
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -176,7 +176,7 @@ int32_t Bcorrectfilename(char *filename, int32_t removefn)
|
|||
char *tokarr[64], *first, *next = NULL, *token;
|
||||
int32_t i, ntok = 0, leadslash = 0, trailslash = 0;
|
||||
|
||||
fn = Bstrdup(filename);
|
||||
fn = Xstrdup(filename);
|
||||
if (!fn) return -1;
|
||||
|
||||
for (first=fn; *first; first++)
|
||||
|
@ -301,7 +301,7 @@ char *Bgetsystemdrives(void)
|
|||
number++;
|
||||
}
|
||||
|
||||
str = p = (char *)Bmalloc(1 + (3 * number));
|
||||
str = p = (char *)Xmalloc(1 + (3 * number));
|
||||
if (!str)
|
||||
return NULL;
|
||||
|
||||
|
@ -349,12 +349,12 @@ BDIR *Bopendir(const char *name)
|
|||
BDIR_real *dirr;
|
||||
#ifdef _MSC_VER
|
||||
char *t, *tt;
|
||||
t = (char *)Bmalloc(Bstrlen(name) + 1 + 4);
|
||||
t = (char *)Xmalloc(Bstrlen(name) + 1 + 4);
|
||||
if (!t)
|
||||
return NULL;
|
||||
#endif
|
||||
|
||||
dirr = (BDIR_real *)Bmalloc(sizeof(BDIR_real) + Bstrlen(name));
|
||||
dirr = (BDIR_real *)Xmalloc(sizeof(BDIR_real) + Bstrlen(name));
|
||||
if (!dirr)
|
||||
{
|
||||
#ifdef _MSC_VER
|
||||
|
@ -430,7 +430,7 @@ struct Bdirent *Breaddir(BDIR *dir)
|
|||
dirr->info.size = 0;
|
||||
dirr->info.mtime = 0;
|
||||
|
||||
char *fn = (char *)Bmalloc(Bstrlen(dirr->name) + 1 + dirr->info.namlen + 1);
|
||||
char *fn = (char *)Xmalloc(Bstrlen(dirr->name) + 1 + dirr->info.namlen + 1);
|
||||
if (fn)
|
||||
{
|
||||
Bsprintf(fn, "%s/%s", dirr->name, dirr->info.name);
|
||||
|
|
|
@ -2622,8 +2622,8 @@ static int32_t defsparser(scriptfile *script)
|
|||
|
||||
for (; previous_usermaphacks < num_usermaphacks; previous_usermaphacks++)
|
||||
{
|
||||
usermaphacks[previous_usermaphacks].mhkfile = mhkfile ? Bstrdup(mhkfile) : NULL;
|
||||
usermaphacks[previous_usermaphacks].title = title ? Bstrdup(title) : NULL;
|
||||
usermaphacks[previous_usermaphacks].mhkfile = mhkfile ? Xstrdup(mhkfile) : NULL;
|
||||
usermaphacks[previous_usermaphacks].title = title ? Xstrdup(title) : NULL;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -7640,8 +7640,7 @@ int32_t enginePreInit(void)
|
|||
for (i=0; i<(signed)ARRAY_SIZE(dynarray); i++)
|
||||
size += dynarray[i].size;
|
||||
|
||||
if ((blockptr = Bcalloc(1, size)) == NULL)
|
||||
return 1;
|
||||
blockptr = Xcalloc(1, size);
|
||||
|
||||
size = 0;
|
||||
|
||||
|
@ -10063,7 +10062,7 @@ int32_t qloadkvx(int32_t voxindex, const char *filename)
|
|||
}
|
||||
|
||||
Bfree(voxfilenames[voxindex]);
|
||||
voxfilenames[voxindex] = Bstrdup(filename);
|
||||
voxfilenames[voxindex] = Xstrdup(filename);
|
||||
g_haveVoxels = 1;
|
||||
#endif
|
||||
|
||||
|
|
|
@ -110,7 +110,7 @@ int32_t loadwgl(const char *driver)
|
|||
return -1;
|
||||
}
|
||||
|
||||
gldriver = Bstrdup(driver);
|
||||
gldriver = Xstrdup(driver);
|
||||
|
||||
bwglCreateContext = (bwglCreateContextProcPtr) GETPROC("wglCreateContext");
|
||||
bwglDeleteContext = (bwglDeleteContextProcPtr) GETPROC("wglDeleteContext");
|
||||
|
@ -211,7 +211,7 @@ int32_t loadglulibrary(const char *driver)
|
|||
return -1;
|
||||
}
|
||||
|
||||
glulibrary = Bstrdup(driver);
|
||||
glulibrary = Xstrdup(driver);
|
||||
|
||||
bgluTessBeginContour = (bgluTessBeginContourProcPtr) GLUGETPROC("gluTessBeginContour");
|
||||
bgluTessBeginPolygon = (bgluTessBeginPolygonProcPtr) GLUGETPROC("gluTessBeginPolygon");
|
||||
|
|
|
@ -45,7 +45,7 @@ static GLuint compileShader(GLenum shaderType, const char* const source)
|
|||
OSD_Printf("Compile Status: %u\n", compileStatus);
|
||||
if (logLength > 0)
|
||||
{
|
||||
char *infoLog = (char*) Bmalloc(logLength);
|
||||
char *infoLog = (char*) Xmalloc(logLength);
|
||||
glGetShaderInfoLog(shaderID, logLength, &logLength, infoLog);
|
||||
OSD_Printf("Log:\n%s\n", infoLog);
|
||||
Bfree(infoLog);
|
||||
|
|
|
@ -1403,7 +1403,7 @@ static int32_t kpegrend(const char *kfilebuf, int32_t kfilength,
|
|||
zz += dctx[z]*dcty[z];
|
||||
}
|
||||
z = zz*64*sizeof(int16_t);
|
||||
dctbuf = (int16_t *)Bmalloc(z); if (!dctbuf) return -1;
|
||||
dctbuf = (int16_t *)Xmalloc(z); if (!dctbuf) return -1;
|
||||
Bmemset(dctbuf,0,z);
|
||||
for (z=zz=0; z<gnumcomponents; z++) { dctptr[z] = &dctbuf[zz*64]; zz += dctx[z]*dcty[z]; }
|
||||
}
|
||||
|
@ -2401,14 +2401,14 @@ static int32_t kzcheckhashsiz(int32_t siz)
|
|||
if (!kzhashbuf) //Initialize hash table on first call
|
||||
{
|
||||
Bmemset(kzhashead,-1,sizeof(kzhashead));
|
||||
kzhashbuf = (char *)Bmalloc(KZHASHINITSIZE); if (!kzhashbuf) return 0;
|
||||
kzhashbuf = (char *)Xmalloc(KZHASHINITSIZE); if (!kzhashbuf) return 0;
|
||||
kzhashpos = 0; kzlastfnam = -1; kzhashsiz = KZHASHINITSIZE; kzdirnamhead = -1;
|
||||
}
|
||||
if (kzhashpos+siz > kzhashsiz) //Make sure string fits in kzhashbuf
|
||||
{
|
||||
int32_t i = kzhashsiz; do { i <<= 1; }
|
||||
while (kzhashpos+siz > i);
|
||||
kzhashbuf = (char *)Brealloc(kzhashbuf,i); if (!kzhashbuf) return 0;
|
||||
kzhashbuf = (char *)Xrealloc(kzhashbuf,i); if (!kzhashbuf) return 0;
|
||||
kzhashsiz = i;
|
||||
}
|
||||
return 1;
|
||||
|
|
|
@ -802,13 +802,13 @@ int32_t mdloadskin(md2model_t *m, int32_t number, int32_t pal, int32_t surf)
|
|||
lastfn = fn; // careful...
|
||||
if (!lastpic)
|
||||
{
|
||||
lastpic = (coltype *)Bmalloc(siz.x*siz.y*sizeof(coltype));
|
||||
lastpic = (coltype *)Xmalloc(siz.x*siz.y*sizeof(coltype));
|
||||
lastsize = siz.x*siz.y;
|
||||
}
|
||||
else if (lastsize < siz.x*siz.y)
|
||||
{
|
||||
Bfree(lastpic);
|
||||
lastpic = (coltype *)Bmalloc(siz.x*siz.y*sizeof(coltype));
|
||||
lastpic = (coltype *)Xmalloc(siz.x*siz.y*sizeof(coltype));
|
||||
}
|
||||
if (lastpic)
|
||||
Bmemcpy(lastpic, pic, siz.x*siz.y*sizeof(coltype));
|
||||
|
|
|
@ -171,7 +171,7 @@ extern "C" {
|
|||
} \
|
||||
MZ_MACRO_END
|
||||
|
||||
tinfl_status tinfl_decompress(tinfl_decompressor *r, const mz_uint8 *pIn_buf_next, size_t *pIn_buf_size, mz_uint8 *pOut_buf_start, mz_uint8 *pOut_buf_next, size_t *pOut_buf_size, const mz_uint32 decomp_flags)
|
||||
tinfl_status tinfl_decompress(tinfl_decompressor *r, const mz_uint8 *pIn_buf_next, size_t *pIn_buf_size, mz_uint8 *pOut_buf_start, mz_uint8 *pOut_buf_next, size_t *pOut_buf_size, mz_uint32 decomp_flags)
|
||||
{
|
||||
static const int s_length_base[31] = { 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0 };
|
||||
static const int s_length_extra[31] = { 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0, 0, 0 };
|
||||
|
|
|
@ -659,16 +659,16 @@ static int32_t osdfunc_toggle(osdfuncparm_t const * const parm)
|
|||
//
|
||||
void OSD_Init(void)
|
||||
{
|
||||
osd = (osdmain_t *)Bcalloc(1, sizeof(osdmain_t));
|
||||
osd = (osdmain_t *)Xcalloc(1, sizeof(osdmain_t));
|
||||
|
||||
mutex_init(&osd->mutex);
|
||||
|
||||
if (!osd->keycode) osd->keycode = sc_Tilde;
|
||||
|
||||
osd->text.buf = (char *)Bmalloc(OSDBUFFERSIZE);
|
||||
osd->text.fmt = (char *)Bmalloc(OSDBUFFERSIZE);
|
||||
osd->editor.buf = (char *)Bmalloc(OSDEDITLENGTH);
|
||||
osd->editor.tmp = (char *)Bmalloc(OSDEDITLENGTH);
|
||||
osd->text.buf = (char *)Xmalloc(OSDBUFFERSIZE);
|
||||
osd->text.fmt = (char *)Xmalloc(OSDBUFFERSIZE);
|
||||
osd->editor.buf = (char *)Xmalloc(OSDEDITLENGTH);
|
||||
osd->editor.tmp = (char *)Xmalloc(OSDEDITLENGTH);
|
||||
|
||||
Bmemset(osd->text.buf, asc_Space, OSDBUFFERSIZE);
|
||||
Bmemset(osd->text.fmt, osd->draw.textpal + (osd->draw.textshade<<5), OSDBUFFERSIZE);
|
||||
|
@ -1394,8 +1394,8 @@ void OSD_ResizeDisplay(int32_t w, int32_t h)
|
|||
j = min(newmaxlines, osd->text.maxlines);
|
||||
k = min(newcols, osd->draw.cols);
|
||||
|
||||
newtext = (char *)Bmalloc(OSDBUFFERSIZE);
|
||||
newfmt = (char *)Bmalloc(OSDBUFFERSIZE);
|
||||
newtext = (char *)Xmalloc(OSDBUFFERSIZE);
|
||||
newfmt = (char *)Xmalloc(OSDBUFFERSIZE);
|
||||
|
||||
Bmemset(newtext, asc_Space, OSDBUFFERSIZE);
|
||||
|
||||
|
@ -1919,7 +1919,7 @@ int32_t OSD_RegisterFunction(const char *pszName, const char *pszDesc, int32_t (
|
|||
void OSD_SetVersion(const char *pszVersion, int osdShade, int osdPal)
|
||||
{
|
||||
DO_FREE_AND_NULL(osd->version.buf);
|
||||
osd->version.buf = Bstrdup(pszVersion);
|
||||
osd->version.buf = Xstrdup(pszVersion);
|
||||
osd->version.len = Bstrlen(pszVersion);
|
||||
osd->version.shade = osdShade;
|
||||
osd->version.pal = osdPal;
|
||||
|
|
|
@ -447,7 +447,7 @@ static GLuint polymost2_compileShader(GLenum shaderType, const char* const sourc
|
|||
OSD_Printf("Compile Status: %u\n", compileStatus);
|
||||
if (logLength > 0)
|
||||
{
|
||||
char *infoLog = (char*) malloc(logLength);
|
||||
char *infoLog = (char*)Xmalloc(logLength);
|
||||
glGetShaderInfoLog(shaderID, logLength, &logLength, infoLog);
|
||||
OSD_Printf("Log:\n%s\n", infoLog);
|
||||
free(infoLog);
|
||||
|
@ -2470,13 +2470,13 @@ int32_t gloadtile_hi(int32_t dapic,int32_t dapalnum, int32_t facen, hicreplctyp
|
|||
lastfn = fn; // careful...
|
||||
if (!lastpic)
|
||||
{
|
||||
lastpic = (coltype *)Bmalloc(siz.x*siz.y*sizeof(coltype));
|
||||
lastpic = (coltype *)Xmalloc(siz.x*siz.y*sizeof(coltype));
|
||||
lastsize = siz.x*siz.y;
|
||||
}
|
||||
else if (lastsize < siz.x*siz.y)
|
||||
{
|
||||
Bfree(lastpic);
|
||||
lastpic = (coltype *)Bmalloc(siz.x*siz.y*sizeof(coltype));
|
||||
lastpic = (coltype *)Xmalloc(siz.x*siz.y*sizeof(coltype));
|
||||
}
|
||||
if (lastpic)
|
||||
Bmemcpy(lastpic, pic, siz.x*siz.y*sizeof(coltype));
|
||||
|
|
|
@ -480,7 +480,7 @@ int main(int argc, char *argv[])
|
|||
#ifdef _WIN32
|
||||
char *argvbuf;
|
||||
int32_t buildargc = win_buildargs(&argvbuf);
|
||||
const char **buildargv = (const char **) Bmalloc(sizeof(char *)*(buildargc+1));
|
||||
const char **buildargv = (const char **) Xmalloc(sizeof(char *)*(buildargc+1));
|
||||
char *wp = argvbuf;
|
||||
|
||||
for (bssize_t i=0; i<buildargc; i++, wp++)
|
||||
|
@ -832,15 +832,15 @@ int32_t initinput(void)
|
|||
joystick.numHats = min((36-joystick.numButtons)/4,SDL_JoystickNumHats(joydev));
|
||||
initprintf("Joystick 1 has %d axes, %d buttons, and %d hat(s).\n", joystick.numAxes, joystick.numButtons, joystick.numHats);
|
||||
|
||||
joystick.pAxis = (int32_t *)Bcalloc(joystick.numAxes, sizeof(int32_t));
|
||||
joystick.pAxis = (int32_t *)Xcalloc(joystick.numAxes, sizeof(int32_t));
|
||||
|
||||
if (joystick.numHats)
|
||||
joystick.pHat = (int32_t *)Bcalloc(joystick.numHats, sizeof(int32_t));
|
||||
joystick.pHat = (int32_t *)Xcalloc(joystick.numHats, sizeof(int32_t));
|
||||
|
||||
for (i = 0; i < joystick.numHats; i++) joystick.pHat[i] = -1; // centre
|
||||
|
||||
joydead = (uint16_t *)Bcalloc(joystick.numAxes, sizeof(uint16_t));
|
||||
joysatur = (uint16_t *)Bcalloc(joystick.numAxes, sizeof(uint16_t));
|
||||
joydead = (uint16_t *)Xcalloc(joystick.numAxes, sizeof(uint16_t));
|
||||
joysatur = (uint16_t *)Xcalloc(joystick.numAxes, sizeof(uint16_t));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -237,7 +237,7 @@ void texcache_syncmemcache(void)
|
|||
if (!texcache.buf || texcache.handle == -1 || len <= (int32_t)texcache.memsize)
|
||||
return;
|
||||
|
||||
texcache.buf = (uint8_t *)Brealloc(texcache.buf, len);
|
||||
texcache.buf = (uint8_t *)Xrealloc(texcache.buf, len);
|
||||
|
||||
if (!texcache.buf)
|
||||
{
|
||||
|
@ -453,8 +453,12 @@ char const * texcache_calcid(char *outbuf, const char *filename, const int32_t l
|
|||
Bstrcpy(id.name, filename);
|
||||
|
||||
size_t const fnlen = Bstrlen(filename);
|
||||
while (Bstrlen(id.name) < BMAX_PATH - fnlen)
|
||||
size_t idlen = Bstrlen(id.name);
|
||||
while (idlen < BMAX_PATH - fnlen)
|
||||
{
|
||||
Bstrcat(id.name, filename);
|
||||
idlen += fnlen;
|
||||
}
|
||||
|
||||
Bsprintf(outbuf, "%08x%08x%08x",
|
||||
XXH32((uint8_t *)id.name, fnlen, TEXCACHEMAGIC[3]),
|
||||
|
@ -839,7 +843,7 @@ void texcache_setupmemcache(void)
|
|||
if (texcache.memsize <= 0)
|
||||
return;
|
||||
|
||||
texcache.buf = (uint8_t *)Brealloc(texcache.buf, texcache.memsize);
|
||||
texcache.buf = (uint8_t *)Xrealloc(texcache.buf, texcache.memsize);
|
||||
|
||||
if (!texcache.buf)
|
||||
{
|
||||
|
|
|
@ -97,7 +97,7 @@ static void win_printversion(void)
|
|||
break;
|
||||
}
|
||||
|
||||
char *str = (char *)Bcalloc(1, 256);
|
||||
char *str = (char *)Xcalloc(1, 256);
|
||||
int l;
|
||||
|
||||
if (pwinever)
|
||||
|
@ -336,7 +336,7 @@ int32_t addsearchpath_ProgramFiles(const char *p)
|
|||
{
|
||||
if (ProgramFiles[i])
|
||||
{
|
||||
char *buffer = (char*)Bmalloc((strlen(ProgramFiles[i])+1+strlen(p)+1)*sizeof(char));
|
||||
char *buffer = (char*)Xmalloc((strlen(ProgramFiles[i])+1+strlen(p)+1)*sizeof(char));
|
||||
Bsprintf(buffer,"%s/%s",ProgramFiles[i],p);
|
||||
if (addsearchpath(buffer) == 0) // if any work, return success
|
||||
returncode = 0;
|
||||
|
@ -351,7 +351,7 @@ int32_t win_buildargs(char **argvbuf)
|
|||
{
|
||||
int32_t buildargc = 0;
|
||||
|
||||
*argvbuf = Bstrdup(GetCommandLine());
|
||||
*argvbuf = Xstrdup(GetCommandLine());
|
||||
|
||||
if (*argvbuf)
|
||||
{
|
||||
|
|
|
@ -301,7 +301,7 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpCmdLine, int nC
|
|||
}
|
||||
|
||||
// carve up the command line into more recognizable pieces
|
||||
argvbuf = Bstrdup(GetCommandLine());
|
||||
argvbuf = Xstrdup(GetCommandLine());
|
||||
_buildargc = 0;
|
||||
if (argvbuf)
|
||||
{
|
||||
|
@ -363,7 +363,7 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpCmdLine, int nC
|
|||
}
|
||||
*wp = 0;
|
||||
|
||||
_buildargv = (const char **)Bmalloc(sizeof(char *)*(_buildargc+1));
|
||||
_buildargv = (const char **)Xmalloc(sizeof(char *)*(_buildargc+1));
|
||||
wp = argvbuf;
|
||||
for (i=0; i<_buildargc; i++,wp++)
|
||||
{
|
||||
|
@ -904,7 +904,7 @@ static BOOL CALLBACK InitDirectInput_enumobjects(LPCDIDEVICEOBJECTINSTANCE lpddo
|
|||
{
|
||||
//initprintf(" Axis: %s (dwOfs=%d)\n", lpddoi->tszName, lpddoi->dwOfs);
|
||||
|
||||
axisdefs[ typecounts[0] ].name = Bstrdup(lpddoi->tszName);
|
||||
axisdefs[ typecounts[0] ].name = Xstrdup(lpddoi->tszName);
|
||||
axisdefs[ typecounts[0] ].ofs = lpddoi->dwOfs;
|
||||
|
||||
typecounts[0]++;
|
||||
|
@ -913,7 +913,7 @@ static BOOL CALLBACK InitDirectInput_enumobjects(LPCDIDEVICEOBJECTINSTANCE lpddo
|
|||
{
|
||||
//initprintf(" Button: %s (dwOfs=%d)\n", lpddoi->tszName, lpddoi->dwOfs);
|
||||
|
||||
buttondefs[ typecounts[1] ].name = Bstrdup(lpddoi->tszName);
|
||||
buttondefs[ typecounts[1] ].name = Xstrdup(lpddoi->tszName);
|
||||
buttondefs[ typecounts[1] ].ofs = lpddoi->dwOfs;
|
||||
|
||||
typecounts[1]++;
|
||||
|
@ -922,7 +922,7 @@ static BOOL CALLBACK InitDirectInput_enumobjects(LPCDIDEVICEOBJECTINSTANCE lpddo
|
|||
{
|
||||
//initprintf(" POV: %s (dwOfs=%d)\n", lpddoi->tszName, lpddoi->dwOfs);
|
||||
|
||||
hatdefs[ typecounts[2] ].name = Bstrdup(lpddoi->tszName);
|
||||
hatdefs[ typecounts[2] ].name = Xstrdup(lpddoi->tszName);
|
||||
hatdefs[ typecounts[2] ].ofs = lpddoi->dwOfs;
|
||||
|
||||
typecounts[2]++;
|
||||
|
@ -1039,14 +1039,14 @@ static BOOL InitDirectInput(void)
|
|||
joystick.numHats = (uint8_t)didc.dwPOVs;
|
||||
initprintf("Controller has %d axes, %d buttons, and %d hat(s).\n",joystick.numAxes,joystick.numButtons,joystick.numHats);
|
||||
|
||||
axisdefs = (struct _joydef *)Bcalloc(didc.dwAxes, sizeof(struct _joydef));
|
||||
buttondefs = (struct _joydef *)Bcalloc(didc.dwButtons, sizeof(struct _joydef));
|
||||
axisdefs = (struct _joydef *)Xcalloc(didc.dwAxes, sizeof(struct _joydef));
|
||||
buttondefs = (struct _joydef *)Xcalloc(didc.dwButtons, sizeof(struct _joydef));
|
||||
if (didc.dwPOVs)
|
||||
hatdefs = (struct _joydef *)Bcalloc(didc.dwPOVs, sizeof(struct _joydef));
|
||||
hatdefs = (struct _joydef *)Xcalloc(didc.dwPOVs, sizeof(struct _joydef));
|
||||
|
||||
joystick.pAxis = (int32_t *)Bcalloc(didc.dwAxes, sizeof(int32_t));
|
||||
joystick.pAxis = (int32_t *)Xcalloc(didc.dwAxes, sizeof(int32_t));
|
||||
if (didc.dwPOVs)
|
||||
joystick.pHat = (int32_t *)Bcalloc(didc.dwPOVs, sizeof(int32_t));
|
||||
joystick.pHat = (int32_t *)Xcalloc(didc.dwPOVs, sizeof(int32_t));
|
||||
|
||||
result = IDirectInputDevice7_EnumObjects(dev2, InitDirectInput_enumobjects, (LPVOID)typecounts, DIDFT_ALL);
|
||||
if (FAILED(result)) { IDirectInputDevice7_Release(dev2); HorribleDInputDeath("Failed getting controller features", result); }
|
||||
|
@ -2029,7 +2029,7 @@ int32_t videoUpdatePalette(int32_t start, int32_t num)
|
|||
|
||||
if (num > 0)
|
||||
{
|
||||
rgb = (RGBQUAD *)Bmalloc(sizeof(RGBQUAD)*num);
|
||||
rgb = (RGBQUAD *)Xmalloc(sizeof(RGBQUAD)*num);
|
||||
for (i=start, n=0; n<num; i++, n++)
|
||||
{
|
||||
rgb[n].rgbBlue = lpal.palPalEntry[i].peBlue;
|
||||
|
@ -2406,7 +2406,7 @@ static int32_t SetupDirectDraw(int32_t width, int32_t height)
|
|||
}
|
||||
|
||||
// initprintf(" - Allocating offscreen buffer\n");
|
||||
lpOffscreen = (char *)Bmalloc((width|1)*height);
|
||||
lpOffscreen = (char *)Xmalloc((width|1)*height);
|
||||
if (!lpOffscreen)
|
||||
{
|
||||
ShowErrorBox("Failure allocating offscreen buffer");
|
||||
|
@ -2821,7 +2821,7 @@ static int32_t SetupOpenGL(int32_t width, int32_t height, int32_t bitspp)
|
|||
glinfo.texcompr = 0;
|
||||
|
||||
// process the extensions string and flag stuff we recognize
|
||||
p = (GLubyte *)Bstrdup(glinfo.extensions);
|
||||
p = (GLubyte *)Xstrdup(glinfo.extensions);
|
||||
p3 = p;
|
||||
while ((p2 = (GLubyte *)Bstrtoken(p3==p?(char *)p:NULL, " ", (char **)&p3, 1)) != NULL)
|
||||
{
|
||||
|
|
|
@ -756,7 +756,7 @@ static void G_ParseSteamKeyValuesForPaths(const char *vdf)
|
|||
if (size <= 0)
|
||||
return;
|
||||
|
||||
vdfbufstart = vdfbuf = (char*)Bmalloc(size);
|
||||
vdfbufstart = vdfbuf = (char*)Xmalloc(size);
|
||||
size = (int32_t)Bread(fd, vdfbuf, size);
|
||||
Bclose(fd);
|
||||
vdfbufend = vdfbuf + size;
|
||||
|
|
|
@ -90,12 +90,12 @@ void CONTROL_ClearAllBinds(void)
|
|||
|
||||
void CONTROL_BindKey(int i, char const * const cmd, int repeat, char const * const keyname)
|
||||
{
|
||||
BIND(CONTROL_KeyBinds[i], Bstrdup(cmd), repeat, keyname);
|
||||
BIND(CONTROL_KeyBinds[i], Xstrdup(cmd), repeat, keyname);
|
||||
}
|
||||
|
||||
void CONTROL_BindMouse(int i, char const * const cmd, int repeat, char const * const keyname)
|
||||
{
|
||||
BIND(CONTROL_KeyBinds[MAXBOUNDKEYS + i], Bstrdup(cmd), repeat, keyname);
|
||||
BIND(CONTROL_KeyBinds[MAXBOUNDKEYS + i], Xstrdup(cmd), repeat, keyname);
|
||||
}
|
||||
|
||||
void CONTROL_FreeKeyBind(int i)
|
||||
|
|
|
@ -156,7 +156,7 @@ ScriptSectionType * SCRIPT_AddSection(int32_t scripthandle, const char * section
|
|||
if (s) return s;
|
||||
|
||||
AllocSection(s);
|
||||
s->name = Bstrdup(sectionname);
|
||||
s->name = Xstrdup(sectionname);
|
||||
if (!SCRIPT(scripthandle,apScript))
|
||||
{
|
||||
SCRIPT(scripthandle,apScript) = s;
|
||||
|
@ -205,7 +205,7 @@ void SCRIPT_AddEntry(int32_t scripthandle, const char * sectionname, const char
|
|||
if (!e)
|
||||
{
|
||||
AllocEntry(e);
|
||||
e->name = Bstrdup(entryname);
|
||||
e->name = Xstrdup(entryname);
|
||||
if (!s->entries)
|
||||
{
|
||||
s->entries = e;
|
||||
|
@ -220,7 +220,7 @@ void SCRIPT_AddEntry(int32_t scripthandle, const char * sectionname, const char
|
|||
}
|
||||
|
||||
Bfree(e->value);
|
||||
e->value = Bstrdup(entryvalue);
|
||||
e->value = Xstrdup(entryvalue);
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue