diff options
Diffstat (limited to 'plugins/NewStory')
-rw-r--r-- | plugins/NewStory/src/history_array.cpp | 17 | ||||
-rw-r--r-- | plugins/NewStory/src/history_array.h | 1 |
2 files changed, 18 insertions, 0 deletions
diff --git a/plugins/NewStory/src/history_array.cpp b/plugins/NewStory/src/history_array.cpp index c9353e88f0..8065adfb20 100644 --- a/plugins/NewStory/src/history_array.cpp +++ b/plugins/NewStory/src/history_array.cpp @@ -635,6 +635,23 @@ int HistoryArray::find(int id, int dir, const Filter &filter) return -1; } +ItemData* HistoryArray::insert(int pos) +{ + int count = getCount(); + ItemData *pNew = &allocateItem(); + ItemData *pPrev = get(count-1, false); + + for (int i = count; i >= pos; i--) { + memcpy(pNew, pPrev, sizeof(ItemData)); + pNew = pPrev; + pPrev = get(i - 1, false); + } + + ItemData tmp; + memcpy(pNew, &tmp, sizeof(tmp)); + return pNew; +} + void HistoryArray::remove(int id) { int pageNo = id / HIST_BLOCK_SIZE; diff --git a/plugins/NewStory/src/history_array.h b/plugins/NewStory/src/history_array.h index 7ec4168bf5..7e8d01b23d 100644 --- a/plugins/NewStory/src/history_array.h +++ b/plugins/NewStory/src/history_array.h @@ -149,6 +149,7 @@ public: } ItemData* get(int id, bool bLoad = false) const; + ItemData* insert(int idx); __forceinline int FindNext(int id, const Filter &filter) { return find(id, +1, filter); } __forceinline int FindPrev(int id, const Filter &filter) { return find(id, -1, filter); } |