Commit f2223e12 authored by Adam Reichold's avatar Adam Reichold Committed by Albert Astals Cid

Assert validity of Object contents where at least constructor or destructor...

Assert validity of Object contents where at least constructor or destructor seem to assume it to catch errors as early as possible when using debug builds.
parent 7c6c1fef
Pipeline #4068 passed with stage
in 7 minutes and 10 seconds
......@@ -91,6 +91,7 @@ Object Object::copy() const {
obj.string = string->copy();
break;
case objName:
case objCmd:
obj.cString = copyString(cString);
break;
case objArray:
......@@ -102,9 +103,6 @@ Object Object::copy() const {
case objStream:
stream->incRef();
break;
case objCmd:
obj.cString = copyString(cString);
break;
default:
break;
}
......@@ -124,6 +122,7 @@ void Object::free() {
delete string;
break;
case objName:
case objCmd:
gfree(cString);
break;
case objArray:
......@@ -141,9 +140,6 @@ void Object::free() {
delete stream;
}
break;
case objCmd:
gfree(cString);
break;
default:
break;
}
......
......@@ -37,6 +37,7 @@
#pragma interface
#endif
#include <cassert>
#include <set>
#include <stdio.h>
#include <string.h>
......@@ -156,15 +157,15 @@ public:
explicit Object(GooString *stringA)
{ constructObj(objString); string = stringA; }
Object(ObjType typeA, const char *stringA)
{ constructObj(typeA); cString = copyString(stringA); }
{ assert(typeA == objName || typeA == objCmd); assert(stringA); constructObj(typeA); cString = copyString(stringA); }
explicit Object(long long int64gA)
{ constructObj(objInt64); int64g = int64gA; }
explicit Object(Array *arrayA)
{ constructObj(objArray); array = arrayA; }
{ assert(arrayA); constructObj(objArray); array = arrayA; }
explicit Object(Dict *dictA)
{ constructObj(objDict); dict = dictA; }
{ assert(dictA); constructObj(objDict); dict = dictA; }
explicit Object(Stream *streamA)
{ constructObj(objStream); stream = streamA; }
{ assert(streamA); constructObj(objStream); stream = streamA; }
Object(int numA, int genA)
{ constructObj(objRef); ref.num = numA; ref.gen = genA; }
template<typename T> Object(T) = delete;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment