MCPcopy Create free account
hub / github.com/NetHack/NetHack / nhl_alloc

Function nhl_alloc

src/nhlua.c:2968–2987  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2966RESTORE_WARNING_CONDEXPR_IS_CONSTANT
2967
2968staticfn void *
2969nhl_alloc(void *ud, void *ptr, size_t osize UNUSED, size_t nsize)
2970{
2971 nhl_user_data *nud = ud;
2972
2973 if (nsize == 0) {
2974 if (ptr != NULL) {
2975 free(ptr);
2976 }
2977 return NULL;
2978 }
2979
2980 /* Check nud->L because it will be NULL during state init. */
2981 if (nud && nud->L && nud->memlimit) { /* this state is size limited */
2982 if (nhl_getmeminuse(nud->L) > nud->memlimit)
2983 return NULL;
2984 }
2985
2986 return re_alloc(ptr, (unsigned) nsize);
2987}
2988
2989DISABLE_WARNING_UNREACHABLE_CODE
2990

Callers 2

nhl_doneFunction · 0.85
nhlL_newstateFunction · 0.85

Calls 2

nhl_getmeminuseFunction · 0.85
re_allocFunction · 0.85

Tested by

no test coverage detected