int32_t Q_STAutoRegister(stable_t *st, const char *string) { int result; assert(st != NULL && st->st != NULL && string != NULL); result = nfst_to_symbol((struct nfst_StringTable *)st->st, string); if (result == NFST_STRING_TABLE_FULL) { if (Q_STGrow(st,st->size * 2)) { result = nfst_to_symbol((struct nfst_StringTable *)st->st, string); } } if (result == NFST_STRING_TABLE_FULL) { Com_Printf(S_COLOR_RED"Error: could not register string: %s\n",string); } return result; }
int32_t Q_STRegister(stable_t *st, const char *string) { int result = nfst_to_symbol((struct nfst_StringTable *)st->st, string); if (result == NFST_STRING_TABLE_FULL && st->heap) { void *new_one = NULL; int newsize = st->size * 2; if ((new_one = Z_Realloc(st->st, newsize)) != NULL) { st->st = new_one; st->size = newsize; nfst_grow((struct nfst_StringTable *)st->st, newsize); result = nfst_to_symbol((struct nfst_StringTable *)st->st, string); } } if (result == NFST_STRING_TABLE_FULL) { Com_Printf(S_COLOR_RED"Error: could not register string: %s\n",string); } return result; }
// Adds the string `s` to the config data and returns its reference. nfcd_loc nfcd_add_string(struct ConfigData **cdp, const char *s) { struct ConfigData *cd = *cdp; struct nfst_StringTable *st = STRINGTABLE(cd); int sym = nfst_to_symbol(st, s); while (sym < 0) { int string_bytes = cd->total_bytes - cd->allocated_bytes; int new_string_bytes = string_bytes * 2; int new_total_bytes = cd->allocated_bytes + new_string_bytes; cd = (ConfigData*)cd->realloc(cd->realloc_user_data, cd, cd->total_bytes, new_total_bytes, __FILE__, __LINE__); cd->total_bytes = new_total_bytes; st = STRINGTABLE(cd); nfst_grow(st, new_string_bytes); sym = nfst_to_symbol(st, s); *cdp = cd; } return MAKE_LOC(NFCD_TYPE_STRING, sym); }
int32_t Q_STRegister(const stable_t *st, const char *string) { assert(st != NULL && st->st != NULL && string != NULL); return nfst_to_symbol((struct nfst_StringTable *)st->st, string);; }