mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-05-11 10:10:48 +00:00
[gamecode] Make non-clearing version of PR_RESNEW
This commit is contained in:
parent
ce2ffac078
commit
1f8c4465a2
1 changed files with 10 additions and 4 deletions
|
@ -1536,7 +1536,7 @@ void *PR_Resources_Find (progs_t *pr, const char *name);
|
||||||
\return A pointer to the new resource, or null if no more could
|
\return A pointer to the new resource, or null if no more could
|
||||||
be allocated.
|
be allocated.
|
||||||
*/
|
*/
|
||||||
#define PR_RESNEW(map) \
|
#define PR_RESNEW_NC(map) \
|
||||||
({ \
|
({ \
|
||||||
if (!map._free) { \
|
if (!map._free) { \
|
||||||
int i, size; \
|
int i, size; \
|
||||||
|
@ -1545,7 +1545,7 @@ void *PR_Resources_Find (progs_t *pr, const char *name);
|
||||||
map._map = realloc (map._map, size); \
|
map._map = realloc (map._map, size); \
|
||||||
if (!map._map) \
|
if (!map._map) \
|
||||||
return 0; \
|
return 0; \
|
||||||
map._free = calloc (1024, sizeof (*map._free)); \
|
map._free = malloc (1024 * sizeof (*map._free)); \
|
||||||
if (!map._free) \
|
if (!map._free) \
|
||||||
return 0; \
|
return 0; \
|
||||||
map._map[map._size - 1] = map._free; \
|
map._map[map._size - 1] = map._free; \
|
||||||
|
@ -1555,6 +1555,12 @@ void *PR_Resources_Find (progs_t *pr, const char *name);
|
||||||
} \
|
} \
|
||||||
__auto_type t = map._free; \
|
__auto_type t = map._free; \
|
||||||
map._free = *(typeof (map._free) *) t; \
|
map._free = *(typeof (map._free) *) t; \
|
||||||
|
t; \
|
||||||
|
})
|
||||||
|
|
||||||
|
#define PR_RESNEW(map) \
|
||||||
|
({ \
|
||||||
|
__auto_type t = PR_RESNEW_NC (map); \
|
||||||
memset (t, 0, sizeof (*map._free)); \
|
memset (t, 0, sizeof (*map._free)); \
|
||||||
t; \
|
t; \
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue