diff --git a/source/audiolib/src/flac.cpp b/source/audiolib/src/flac.cpp index 4ee9e5344..0cbaece67 100644 --- a/source/audiolib/src/flac.cpp +++ b/source/audiolib/src/flac.cpp @@ -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); } } } diff --git a/source/audiolib/src/linklist.h b/source/audiolib/src/linklist.h index 76e0854d5..c2aa6facb 100644 --- a/source/audiolib/src/linklist.h +++ b/source/audiolib/src/linklist.h @@ -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) \ diff --git a/source/audiolib/src/xmp.cpp b/source/audiolib/src/xmp.cpp index 91198dcc4..0967312da 100644 --- a/source/audiolib/src/xmp.cpp +++ b/source/audiolib/src/xmp.cpp @@ -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); diff --git a/source/build/src/animvpx.cpp b/source/build/src/animvpx.cpp index 0eb3c1061..92333e8b2 100644 --- a/source/build/src/animvpx.cpp +++ b/source/build/src/animvpx.cpp @@ -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; diff --git a/source/build/src/compat.cpp b/source/build/src/compat.cpp index 6c81653f4..aecab026b 100644 --- a/source/build/src/compat.cpp +++ b/source/build/src/compat.cpp @@ -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); diff --git a/source/build/src/defs.cpp b/source/build/src/defs.cpp index 2b15ddfb9..72bc371df 100644 --- a/source/build/src/defs.cpp +++ b/source/build/src/defs.cpp @@ -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; diff --git a/source/build/src/engine.cpp b/source/build/src/engine.cpp index ece63be9d..cf3161286 100644 --- a/source/build/src/engine.cpp +++ b/source/build/src/engine.cpp @@ -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 diff --git a/source/build/src/glbuild.cpp b/source/build/src/glbuild.cpp index a14268cbd..3c65415ff 100644 --- a/source/build/src/glbuild.cpp +++ b/source/build/src/glbuild.cpp @@ -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"); diff --git a/source/build/src/glsurface.cpp b/source/build/src/glsurface.cpp index 87812f25d..8d5c9668f 100644 --- a/source/build/src/glsurface.cpp +++ b/source/build/src/glsurface.cpp @@ -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); diff --git a/source/build/src/kplib.cpp b/source/build/src/kplib.cpp index 06ac6f5f3..9ed92574c 100644 --- a/source/build/src/kplib.cpp +++ b/source/build/src/kplib.cpp @@ -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 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; diff --git a/source/build/src/mdsprite.cpp b/source/build/src/mdsprite.cpp index 32fc90659..6b8d12fe6 100644 --- a/source/build/src/mdsprite.cpp +++ b/source/build/src/mdsprite.cpp @@ -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)); diff --git a/source/build/src/miniz_tinfl.c b/source/build/src/miniz_tinfl.c index 7ab36df84..27d3b1e1d 100644 --- a/source/build/src/miniz_tinfl.c +++ b/source/build/src/miniz_tinfl.c @@ -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 }; diff --git a/source/build/src/osd.cpp b/source/build/src/osd.cpp index 4a7f5aff2..01681e9c1 100644 --- a/source/build/src/osd.cpp +++ b/source/build/src/osd.cpp @@ -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; diff --git a/source/build/src/polymost.cpp b/source/build/src/polymost.cpp index b92c1dba8..d95bc9752 100644 --- a/source/build/src/polymost.cpp +++ b/source/build/src/polymost.cpp @@ -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)); diff --git a/source/build/src/sdlayer.cpp b/source/build/src/sdlayer.cpp index c24cdf13d..cac70070a 100644 --- a/source/build/src/sdlayer.cpp +++ b/source/build/src/sdlayer.cpp @@ -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; itszName, 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; nname = 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); }