ext/ds_tweakable.h
static int twk__add_string(const char* txt) {
	uint32_t hash = twk_fnv1a(txt);
	int strIdx = twk__find_string(hash);
	if (strIdx != -1) {
		return strIdx;
	}
	size_t l = strlen(txt);
	if ((l + _twkCtx->charBuffer.size + 1) >= _twkCtx->charBuffer.capacity) {
		twk__realloc_char_buffer(&_twkCtx->charBuffer, l * 2);
	}
	if (_twkCtx->charBuffer.count + 1 >= _twkCtx->charBuffer.indexCapacity) {
		twk__reallocate_indices(&_twkCtx->charBuffer, 16);
	}
	size_t current = _twkCtx->charBuffer.size;
	char* dest = _twkCtx->charBuffer.data + current;
	_twkCtx->charBuffer.indices[_twkCtx->charBuffer.count] = current;
	_twkCtx->charBuffer.sizes[_twkCtx->charBuffer.count] = l + 1;
	_twkCtx->charBuffer.hashes[_twkCtx->charBuffer.count] = hash;
	++_twkCtx->charBuffer.count;
	strncpy(dest, txt, l);
	_twkCtx->charBuffer.size += l + 1;
	dest[l] = '\0';
	return _twkCtx->charBuffer.count - 1;
}
// -------------------------------------------------------
// internal add string to char buffer
// -------------------------------------------------------
internal add string to char buffer
internal add string to char buffer
static int twk__add_string(const char* txt) {
	uint32_t hash = twk_fnv1a(txt);
	int strIdx = twk__find_string(hash);
	if (strIdx != -1) {
		return strIdx;
	}
	size_t l = strlen(txt);
	if ((l + _twkCtx->charBuffer.size + 1) >= _twkCtx->charBuffer.capacity) {
		twk__realloc_char_buffer(&_twkCtx->charBuffer, l * 2);
	}
	if (_twkCtx->charBuffer.count + 1 >= _twkCtx->charBuffer.indexCapacity) {
		twk__reallocate_indices(&_twkCtx->charBuffer, 16);
	}
	size_t current = _twkCtx->charBuffer.size;
	char* dest = _twkCtx->charBuffer.data + current;
	_twkCtx->charBuffer.indices[_twkCtx->charBuffer.count] = current;
	_twkCtx->charBuffer.sizes[_twkCtx->charBuffer.count] = l + 1;
	_twkCtx->charBuffer.hashes[_twkCtx->charBuffer.count] = hash;
	++_twkCtx->charBuffer.count;
	strncpy(dest, txt, l);
	_twkCtx->charBuffer.size += l + 1;
	dest[l] = '\0';
	return _twkCtx->charBuffer.count - 1;
}
static int twk__add_string ( const char * txt ) { uint32_t hash = twk_fnv1a ( txt ) ; int strIdx = twk__find_string ( hash ) ; if ( strIdx != -1 ) { return strIdx ; } size_t l = strlen ( txt ) ; if ( ( l + _twkCtx -> charBuffer . size + 1 ) >= _twkCtx -> charBuffer . capacity ) { twk__realloc_char_buffer ( & _twkCtx -> charBuffer , l * 2 ) ; } if ( _twkCtx -> charBuffer . count + 1 >= _twkCtx -> charBuffer . indexCapacity ) { twk__reallocate_indices ( & _twkCtx -> charBuffer , 16 ) ; } size_t current = _twkCtx -> charBuffer . size ; char * dest = _twkCtx -> charBuffer . data + current ; _twkCtx -> charBuffer . indices [ _twkCtx -> charBuffer . count ] = current ; _twkCtx -> charBuffer . sizes [ _twkCtx -> charBuffer . count ] = l + 1 ; _twkCtx -> charBuffer . hashes [ _twkCtx -> charBuffer . count ] = hash ; ++ _twkCtx -> charBuffer . count ; strncpy ( dest , txt , l ) ; _twkCtx -> charBuffer . size += l + 1 ; dest [ l ] = ' \0 ' ; return _twkCtx -> charBuffer . count - 1 ; }
internal add string to char buffer
internal add string to char buffer