external/tinyxml 2_4_1
Change-Id: Id87a03820c20eaa9c9b92028ab859a27872c16da
diff --git a/tinystr.h b/tinystr.h
index aedd2f9..b5ba5e8 100644
--- a/tinystr.h
+++ b/tinystr.h
@@ -217,7 +217,15 @@
{
if (cap)
{
- rep_ = static_cast<Rep*>(operator new(sizeof(Rep) + cap));
+ // Lee: the original form:
+ // rep_ = static_cast<Rep*>(operator new(sizeof(Rep) + cap));
+ // doesn't work in some cases of new being overloaded. Switching
+ // to the normal allocation, although use an 'int' for systems
+ // that are overly picky about structure alignment.
+ const size_type bytesNeeded = sizeof(Rep) + cap;
+ const size_type intsNeeded = ( bytesNeeded + sizeof(int) - 1 ) / sizeof( int );
+ rep_ = reinterpret_cast<Rep*>( new int[ intsNeeded ] );
+
rep_->str[ rep_->size = sz ] = '\0';
rep_->capacity = cap;
}
@@ -231,7 +239,7 @@
{
if (rep_ != &nullrep_)
{
- operator delete(rep_);
+ delete [] rep_;
}
}