From 4a5e58c4f41a8d1f8ebddf9c11cc3daccb9eb4e3 Mon Sep 17 00:00:00 2001 From: Baptiste Lepilleur Date: Fri, 15 Jan 2010 14:56:59 +0000 Subject: [PATCH] Integrated part of Patch #2839016, fixing default iterator initialization when using internal map. --- include/json/value.h | 13 +++++++++++++ src/lib_json/json_valueiterator.inl | 10 +++++++--- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/include/json/value.h b/include/json/value.h index 72fcabd..ce3d3cd 100644 --- a/include/json/value.h +++ b/include/json/value.h @@ -637,6 +637,13 @@ namespace Json { # ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION struct IteratorState { + IteratorState() + : map_(0) + , link_(0) + , itemIndex_(0) + , bucketIndex_(0) + { + } ValueInternalMap *map_; ValueInternalLink *link_; BucketIndex itemIndex_; @@ -729,6 +736,12 @@ namespace Json { # ifndef JSONCPP_DOC_EXCLUDE_IMPLEMENTATION struct IteratorState // Must be a POD { + IteratorState() + : array_(0) + , currentPageIndex_(0) + , currentItemIndex_(0) + { + } ValueInternalArray *array_; Value **currentPageIndex_; unsigned int currentItemIndex_; diff --git a/src/lib_json/json_valueiterator.inl b/src/lib_json/json_valueiterator.inl index d6cc031..898c358 100644 --- a/src/lib_json/json_valueiterator.inl +++ b/src/lib_json/json_valueiterator.inl @@ -14,11 +14,15 @@ ValueIteratorBase::ValueIteratorBase() #ifndef JSON_VALUE_USE_INTERNAL_MAP : current_() , isNull_( true ) -#else -# error fix me // Need to handle uninitialized iterator comparison for experimental maps -#endif { } +#else + : isArray_( true ) + , isNull_( true ) +{ + iterator_.array_ = ValueInternalArray::IteratorState(); +} +#endif #ifndef JSON_VALUE_USE_INTERNAL_MAP