diff --git a/bigpoint_dyntype.c b/bigpoint_dyntype.c index 5fff3c0..d451e9c 100644 --- a/bigpoint_dyntype.c +++ b/bigpoint_dyntype.c @@ -4,6 +4,7 @@ #include #include "bigpoint_dyntype.h" +#include "bigpoint_hash.h" static @@ -24,10 +25,11 @@ __construct(struct BIGPOINT_DYNTYPE * _this, va_list * params) break; case BIGPOINT_DYNTYPE_HASH: + (_this->data)._hash = new(BIGPOINT_HASH); break; default: - (_this->data)._object = NULL; + (_this->data)._hash = NULL; } } @@ -57,7 +59,7 @@ __jsonConst(struct BIGPOINT_DYNTYPE * _this, struct json_object * json) default: _this->type = BIGPOINT_DYNTYPE_NULL; _this->size = 0; - (_this->data)._object = NULL; + (_this->data)._hash = NULL; } } diff --git a/bigpoint_dyntype.h b/bigpoint_dyntype.h index c91ea5f..c1475b8 100644 --- a/bigpoint_dyntype.h +++ b/bigpoint_dyntype.h @@ -5,6 +5,10 @@ #include "bigpoint_cclass.h" +struct BIGPOINT_DYNTYPE; + +#include "bigpoint_hash.h" + enum BIGPOINT_DYNTYPE_TYPES { BIGPOINT_DYNTYPE_NULL = 0, @@ -26,7 +30,8 @@ struct BIGPOINT_DYNTYPE { int _int; double _float; char * _string; - void * _object; + struct BIGPOINT_DYNTYPE ** _array; + struct BIGPOINT_HASH * _hash; } data; }; diff --git a/tests/hash_test.c b/tests/hash_test.c index 644ebb8..71ba5fe 100644 --- a/tests/hash_test.c +++ b/tests/hash_test.c @@ -16,6 +16,7 @@ main(int argc, char * argv[]) { struct BIGPOINT_DYNTYPE * dyn; struct BIGPOINT_HASH * hash = new(BIGPOINT_HASH); + struct json_object * json; dyn = new(BIGPOINT_DYNTYPE, BIGPOINT_DYNTYPE_INT, sizeof(int), 123); bigpoint_hash_set(hash, TEST_KEY1, dyn); @@ -33,9 +34,9 @@ main(int argc, char * argv[]) delete(hash); - hash = newFromJson( - BIGPOINT_HASH, - json_tokener_parse("{\"key1\":123,\"key2\":321}")); + json = json_tokener_parse("{\"key1\":123,\"key2\":321}"); + hash = newFromJson(BIGPOINT_HASH, json); + json_object_put(json); dyn = bigpoint_hash_get(hash, TEST_KEY1); printf("%d\n", (dyn->data)._int);