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

Function StringsBuffer_Remove

src/String.c:893–921  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

891}
892
893void StringsBuffer_Remove(struct StringsBuffer* buffer, int index) {
894 cc_uint32 flags, offset, len;
895 cc_uint32 i, offsetAdj;
896 if (index < 0 || index >= buffer->count) Process_Abort("Tried to remove String past StringsBuffer end");
897
898 flags = buffer->flagsBuffer[index];
899 offset = StringsBuffer_GetOffset(flags);
900 len = StringsBuffer_GetLength(flags);
901
902 /* Imagine buffer is this: AAXXYYZZ, and want to delete XX */
903 /* We iterate from first char of Y to last char of Z, */
904 /* shifting each character two to the left. */
905 for (i = offset + len; i < buffer->totalLength; i++) {
906 buffer->textBuffer[i - len] = buffer->textBuffer[i];
907 }
908
909 /* Adjust text offset of elements after this element */
910 /* Elements may not be in order so must account for that */
911 offsetAdj = StringsBuffer_PackOffset(len);
912 for (i = index; i < buffer->count - 1; i++) {
913 buffer->flagsBuffer[i] = buffer->flagsBuffer[i + 1];
914 if (buffer->flagsBuffer[i] >= flags) {
915 buffer->flagsBuffer[i] -= offsetAdj;
916 }
917 }
918
919 buffer->count--;
920 buffer->totalLength -= len;
921}
922
923static struct StringsBuffer* sort_buffer;
924static void StringsBuffer_QuickSort(int left, int right) {

Callers 4

TabList_DeleteFunction · 0.85
Hotkeys_RemoveTextFunction · 0.85
Options_ReloadFunction · 0.85
EntryList_RemoveFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected