Fixed realloc/delete[] mismatch (thank sawce), corrected some whitespace.

This commit is contained in:
David Anderson 2008-09-21 14:05:13 -07:00
parent 4517031861
commit 6192efc078

View File

@ -202,7 +202,7 @@ public:
} }
~StaticCharBuf() ~StaticCharBuf()
{ {
delete [] buffer; free(buffer);
} }
char* GetWithSize(size_t len) char* GetWithSize(size_t len)
{ {
@ -224,7 +224,7 @@ static cell_t sm_format(IPluginContext *pCtx, const cell_t *params)
size_t res, maxlen; size_t res, maxlen;
int arg = 4; int arg = 4;
bool copy = false; bool copy = false;
char *__copy_buf; char *__copy_buf;
pCtx->LocalToString(params[1], &destbuf); pCtx->LocalToString(params[1], &destbuf);
pCtx->LocalToString(params[3], &fmt); pCtx->LocalToString(params[3], &fmt);
@ -243,17 +243,17 @@ static cell_t sm_format(IPluginContext *pCtx, const cell_t *params)
} }
} }
if (copy) if (copy)
{ {
if (maxlen > sizeof(g_formatbuf)) if (maxlen > sizeof(g_formatbuf))
{ {
__copy_buf = g_extrabuf.GetWithSize(maxlen); __copy_buf = g_extrabuf.GetWithSize(maxlen);
} }
else else
{ {
__copy_buf = g_formatbuf; __copy_buf = g_formatbuf;
} }
} }
buf = (copy) ? __copy_buf : destbuf; buf = (copy) ? __copy_buf : destbuf;
res = atcprintf(buf, maxlen, fmt, pCtx, params, &arg); res = atcprintf(buf, maxlen, fmt, pCtx, params, &arg);