diff options
author | Nat Goodspeed <nat@lindenlab.com> | 2022-11-03 14:58:32 -0400 |
---|---|---|
committer | Nat Goodspeed <nat@lindenlab.com> | 2022-11-03 14:58:32 -0400 |
commit | 9522a0b7c16414fce2103cf58bfdd63aaf0cb01b (patch) | |
tree | 3384f6bbf9dac0e86fa8f39d98d483f1aaf09575 /indra/llcommon/llsd.h | |
parent | 206993f8439ee83f7d010860f421d1e0106daca0 (diff) |
DRTVWR-575: Fix llcommon assumptions that size_t fits in 4 bytes.
It's a little distressing how often we have historically coded S32 or U32 to
pass a length or index.
There are more such assumptions in other viewer subdirectories, but this is a
start.
Diffstat (limited to 'indra/llcommon/llsd.h')
-rw-r--r-- | indra/llcommon/llsd.h | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/indra/llcommon/llsd.h b/indra/llcommon/llsd.h index 24cb9bbce1..f034470da7 100644 --- a/indra/llcommon/llsd.h +++ b/indra/llcommon/llsd.h @@ -313,14 +313,18 @@ public: LLSD& append(const LLSD&); void erase(Integer); LLSD& with(Integer, const LLSD&); - - const LLSD& operator[](Integer) const; - LLSD& operator[](Integer); + + // accept size_t so we can index relative to size() + const LLSD& operator[](size_t) const; + LLSD& operator[](size_t); + // overload to disambiguate [0], [1] et al. + const LLSD& operator[](Integer i) const { return (*this)[size_t(i)]; } + LLSD& operator[](Integer i) { return (*this)[size_t(i)]; } //@} /** @name Iterators */ //@{ - int size() const; + size_t size() const; typedef std::map<String, LLSD>::iterator map_iterator; typedef std::map<String, LLSD>::const_iterator map_const_iterator; |