Mercurial > hg > openttd
changeset 14086:dc04dd0ba0fd draft
(svn r18633) -Codechange: fortify SmallVector a bit more
author | smatz <smatz@openttd.org> |
---|---|
date | Fri, 25 Dec 2009 23:10:20 +0000 |
parents | a39b48478e66 |
children | 5290a3a69842 |
files | src/core/smallvec_type.hpp |
diffstat | 1 files changed, 8 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/src/core/smallvec_type.hpp +++ b/src/core/smallvec_type.hpp @@ -54,7 +54,7 @@ /** * Remove all items from the list and free allocated memory. */ - void Reset() + FORCEINLINE void Reset() { this->items = 0; this->capacity = 0; @@ -76,6 +76,7 @@ /** * Append an item and return it. + * @return pointer to newly allocated item */ FORCEINLINE T *Append() { @@ -144,7 +145,8 @@ return this->Find(item) != this->End(); } - /** Removes given item from this map + /** + * Removes given item from this vector * @param item item to remove * @note it has to be pointer to item in this map. It is overwritten by the last item. */ @@ -223,6 +225,7 @@ */ FORCEINLINE const T *Get(uint index) const { + assert(index < this->items); return &this->data[index]; } @@ -234,6 +237,7 @@ */ FORCEINLINE T *Get(uint index) { + assert(index < this->items); return &this->data[index]; } @@ -245,6 +249,7 @@ */ FORCEINLINE const T &operator[](uint index) const { + assert(index < this->items); return this->data[index]; } @@ -256,6 +261,7 @@ */ FORCEINLINE T &operator[](uint index) { + assert(index < this->items); return this->data[index]; } };