MCPcopy Create free account
hub / github.com/ClassiCube/ClassiCube / StringsBuffer_Add

Function StringsBuffer_Add

src/String.c:866–891  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

864}
865
866void StringsBuffer_Add(struct StringsBuffer* buffer, const cc_string* str) {
867 int textOffset;
868 /* StringsBuffer hasn't been initialised yet, do it here */
869 if (!buffer->_flagsCapacity) StringsBuffer_Init(buffer);
870
871 if (buffer->count == buffer->_flagsCapacity) {
872 Utils_Resize((void**)&buffer->flagsBuffer, &buffer->_flagsCapacity,
873 4, STRINGSBUFFER_FLAGS_DEF_ELEMS, 512);
874 }
875
876 if (str->length > buffer->_lenMask) {
877 Process_Abort("String too big to insert into StringsBuffer");
878 }
879
880 textOffset = buffer->totalLength;
881 if (textOffset + str->length >= buffer->_textCapacity) {
882 Utils_Resize((void**)&buffer->textBuffer, &buffer->_textCapacity,
883 1, STRINGSBUFFER_BUFFER_DEF_SIZE, 8192);
884 }
885
886 Mem_Copy(&buffer->textBuffer[textOffset], str->buffer, str->length);
887 buffer->flagsBuffer[buffer->count] = str->length | StringsBuffer_PackOffset(textOffset);
888
889 buffer->count++;
890 buffer->totalLength += str->length;
891}
892
893void StringsBuffer_Remove(struct StringsBuffer* buffer, int index) {
894 cc_uint32 flags, offset, len;

Callers 13

TabList_SetFunction · 0.85
Chat_AddOfFunction · 0.85
LogInputUsageFunction · 0.85
SysFonts_GetNamesFunction · 0.85
Hotkeys_AddNewHotkeyFunction · 0.85
Hotkeys_AddFunction · 0.85
Options_SetStringFunction · 0.85
Music_AddFileFunction · 0.85
EntryList_LoadFunction · 0.85

Calls 3

StringsBuffer_InitFunction · 0.85
Utils_ResizeFunction · 0.85
Mem_CopyFunction · 0.85

Tested by

no test coverage detected