- Use MAP_FAILED error code for check whether mmap() was successful

- Replace various malloc() with Z_Malloc
- Fix several memory leaks when VM compilation failed and Com_Error is called
- Make failed mmap/VirtualAlloc/malloc calls fatal
This commit is contained in:
Thilo Schulz 2011-02-10 18:45:28 +00:00
parent 5e0d0efd2e
commit 544a1c0c1a
5 changed files with 50 additions and 27 deletions

View file

@ -244,10 +244,10 @@ static void hash_add_label(const char* label, unsigned address)
int labellen;
i %= sizeof(labelhash)/sizeof(labelhash[0]);
h = malloc(sizeof(struct hashentry));
h = Z_Malloc(sizeof(struct hashentry));
labellen = strlen(label) + 1;
h->label = malloc(labellen);
h->label = Z_Malloc(labellen);
memcpy(h->label, label, labellen);
h->address = address;
@ -282,8 +282,8 @@ static void labelhash_free(void)
while(h)
{
struct hashentry* next = h->next;
free(h->label);
free(h);
Z_Free(h->label);
Z_Free(h);
h = next;
++n;
}