diff --git a/src/basic/basic.h b/src/basic/basic.h index d7df564..1485e73 100644 --- a/src/basic/basic.h +++ b/src/basic/basic.h @@ -471,29 +471,6 @@ void BoundedAddError(Array *arr, T item) { if (arr->len + 1 <= arr->cap) arr->data[arr->len++] = item; } -template -T *Alloc(Array *arr, T item) { - TryGrowing(arr); - T *ref = arr->data + arr->len++; - ref[0] = item; - return ref; -} - -template -T *Alloc(Array *arr) { - return Alloc(arr, {}); -} - -template -T *AllocMultiple(Array *arr, int64_t count, bool zero_memory = true) { - TryGrowing(arr, count); - T *result = arr->data + arr->len; - arr->len += count; - if (zero_memory) - for (int64_t i = 0; i < count; i += 1) result[i] = {}; - return result; -} - template void Insert(Array *arr, T item, int64_t index) { if (index == arr->len) { diff --git a/src/text_editor/buffer_history.cpp b/src/text_editor/buffer_history.cpp index fd450df..4f6eec4 100644 --- a/src/text_editor/buffer_history.cpp +++ b/src/text_editor/buffer_history.cpp @@ -1,7 +1,8 @@ void SaveHistoryBeforeMergeCursor(Buffer *buffer, Array *stack, Array &carets) { if (buffer->no_history) return; - HistoryEntry *entry = Alloc(stack); - entry->carets = TightCopy(GetSystemAllocator(), carets); + HistoryEntry entry = {}; + entry.carets = TightCopy(GetSystemAllocator(), carets); + Add(stack, entry); } void SaveHistoryBeforeApplyEdits(Buffer *buffer, Array *stack, Array &edits) {