Remove qcc hunk size limitations.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5940 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
parent
80399796c7
commit
b45ce608c0
1 changed files with 42 additions and 22 deletions
|
@ -21,26 +21,55 @@ void QCC_PR_ResetErrorScope(void);
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
int qccalloced;
|
static struct qcchunk_s
|
||||||
int qcchunksize;
|
{
|
||||||
char *qcchunk;
|
struct qcchunk_s *older;
|
||||||
|
char *data;
|
||||||
|
char *end;
|
||||||
|
} *qcc_hunk;
|
||||||
|
static void qccHunkExtend(size_t minsize)
|
||||||
|
{
|
||||||
|
struct qcchunk_s *n;
|
||||||
|
size_t sz;
|
||||||
|
minsize += sizeof(struct qcchunk_s)+64;
|
||||||
|
sz = max(minsize, 256*1024*1024);
|
||||||
|
|
||||||
|
for (;;)
|
||||||
|
{
|
||||||
|
if (sz < minsize)
|
||||||
|
QCC_Error(ERR_INTERNAL, "Compile hunk was filled");
|
||||||
|
n = malloc(sz);
|
||||||
|
if (n)
|
||||||
|
break;
|
||||||
|
sz /= 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
n->data = (char*)(n+1);
|
||||||
|
n->end = ((char*)n)+sz;
|
||||||
|
n->older = qcc_hunk;
|
||||||
|
qcc_hunk = n;
|
||||||
|
}
|
||||||
void *qccHunkAlloc(size_t mem)
|
void *qccHunkAlloc(size_t mem)
|
||||||
{
|
{
|
||||||
|
char *ret;
|
||||||
mem = (mem + 7)&~7;
|
mem = (mem + 7)&~7;
|
||||||
|
|
||||||
qccalloced+=mem;
|
if (qcc_hunk->data+mem > qcc_hunk->end)
|
||||||
if (qccalloced > qcchunksize)
|
qccHunkExtend(mem);
|
||||||
QCC_Error(ERR_INTERNAL, "Compile hunk was filled");
|
ret = qcc_hunk->data;
|
||||||
|
qcc_hunk->data += mem;
|
||||||
|
|
||||||
memset(qcchunk+qccalloced-mem, 0, mem);
|
memset(ret, 0, mem);
|
||||||
return qcchunk+qccalloced-mem;
|
return ret;
|
||||||
}
|
}
|
||||||
void qccClearHunk(void)
|
void qccClearHunk(void)
|
||||||
{
|
{
|
||||||
if (qcchunk)
|
struct qcchunk_s *t;
|
||||||
|
while (qcc_hunk)
|
||||||
{
|
{
|
||||||
free(qcchunk);
|
t = qcc_hunk;
|
||||||
qcchunk=NULL;
|
qcc_hunk = t->older;
|
||||||
|
free(t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
int qccpersisthunk;
|
int qccpersisthunk;
|
||||||
|
@ -63,18 +92,9 @@ pbool PreCompile(void)
|
||||||
|
|
||||||
qccClearHunk();
|
qccClearHunk();
|
||||||
strcpy(qcc_gamedir, "");
|
strcpy(qcc_gamedir, "");
|
||||||
if (sizeof(void*) > 4)
|
|
||||||
qcchunk = malloc(qcchunksize=512*1024*1024);
|
|
||||||
else
|
|
||||||
qcchunk = malloc(qcchunksize=256*1024*1024);
|
|
||||||
while(!qcchunk && qcchunksize > 8*1024*1024)
|
|
||||||
{
|
|
||||||
qcchunksize /= 2;
|
|
||||||
qcchunk = malloc(qcchunksize);
|
|
||||||
}
|
|
||||||
qccalloced=0;
|
|
||||||
|
|
||||||
return !!qcchunk;
|
qccHunkExtend(0);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
pbool QCC_main (int argc, const char **argv);
|
pbool QCC_main (int argc, const char **argv);
|
||||||
|
|
Loading…
Reference in a new issue