Commit ac539ffa2aad055d01d374bd51a11f104277aad7
1 parent
a9ecc666
small fixes and preparations for further additions. valgrind shows no leaks now
Showing
3 changed files
with
14 additions
and
6 deletions
| @@ -4,6 +4,7 @@ | @@ -4,6 +4,7 @@ | ||
| 4 | #include <json/json.h> | 4 | #include <json/json.h> |
| 5 | 5 | ||
| 6 | #include "bigpoint_dyntype.h" | 6 | #include "bigpoint_dyntype.h" |
| 7 | +#include "bigpoint_hash.h" | ||
| 7 | 8 | ||
| 8 | 9 | ||
| 9 | static | 10 | static |
| @@ -24,10 +25,11 @@ __construct(struct BIGPOINT_DYNTYPE * _this, va_list * params) | @@ -24,10 +25,11 @@ __construct(struct BIGPOINT_DYNTYPE * _this, va_list * params) | ||
| 24 | break; | 25 | break; |
| 25 | 26 | ||
| 26 | case BIGPOINT_DYNTYPE_HASH: | 27 | case BIGPOINT_DYNTYPE_HASH: |
| 28 | + (_this->data)._hash = new(BIGPOINT_HASH); | ||
| 27 | break; | 29 | break; |
| 28 | 30 | ||
| 29 | default: | 31 | default: |
| 30 | - (_this->data)._object = NULL; | 32 | + (_this->data)._hash = NULL; |
| 31 | } | 33 | } |
| 32 | } | 34 | } |
| 33 | 35 | ||
| @@ -57,7 +59,7 @@ __jsonConst(struct BIGPOINT_DYNTYPE * _this, struct json_object * json) | @@ -57,7 +59,7 @@ __jsonConst(struct BIGPOINT_DYNTYPE * _this, struct json_object * json) | ||
| 57 | default: | 59 | default: |
| 58 | _this->type = BIGPOINT_DYNTYPE_NULL; | 60 | _this->type = BIGPOINT_DYNTYPE_NULL; |
| 59 | _this->size = 0; | 61 | _this->size = 0; |
| 60 | - (_this->data)._object = NULL; | 62 | + (_this->data)._hash = NULL; |
| 61 | } | 63 | } |
| 62 | } | 64 | } |
| 63 | 65 |
| @@ -5,6 +5,10 @@ | @@ -5,6 +5,10 @@ | ||
| 5 | 5 | ||
| 6 | #include "bigpoint_cclass.h" | 6 | #include "bigpoint_cclass.h" |
| 7 | 7 | ||
| 8 | +struct BIGPOINT_DYNTYPE; | ||
| 9 | + | ||
| 10 | +#include "bigpoint_hash.h" | ||
| 11 | + | ||
| 8 | 12 | ||
| 9 | enum BIGPOINT_DYNTYPE_TYPES { | 13 | enum BIGPOINT_DYNTYPE_TYPES { |
| 10 | BIGPOINT_DYNTYPE_NULL = 0, | 14 | BIGPOINT_DYNTYPE_NULL = 0, |
| @@ -26,7 +30,8 @@ struct BIGPOINT_DYNTYPE { | @@ -26,7 +30,8 @@ struct BIGPOINT_DYNTYPE { | ||
| 26 | int _int; | 30 | int _int; |
| 27 | double _float; | 31 | double _float; |
| 28 | char * _string; | 32 | char * _string; |
| 29 | - void * _object; | 33 | + struct BIGPOINT_DYNTYPE ** _array; |
| 34 | + struct BIGPOINT_HASH * _hash; | ||
| 30 | } data; | 35 | } data; |
| 31 | }; | 36 | }; |
| 32 | 37 |
| @@ -16,6 +16,7 @@ main(int argc, char * argv[]) | @@ -16,6 +16,7 @@ main(int argc, char * argv[]) | ||
| 16 | { | 16 | { |
| 17 | struct BIGPOINT_DYNTYPE * dyn; | 17 | struct BIGPOINT_DYNTYPE * dyn; |
| 18 | struct BIGPOINT_HASH * hash = new(BIGPOINT_HASH); | 18 | struct BIGPOINT_HASH * hash = new(BIGPOINT_HASH); |
| 19 | + struct json_object * json; | ||
| 19 | 20 | ||
| 20 | dyn = new(BIGPOINT_DYNTYPE, BIGPOINT_DYNTYPE_INT, sizeof(int), 123); | 21 | dyn = new(BIGPOINT_DYNTYPE, BIGPOINT_DYNTYPE_INT, sizeof(int), 123); |
| 21 | bigpoint_hash_set(hash, TEST_KEY1, dyn); | 22 | bigpoint_hash_set(hash, TEST_KEY1, dyn); |
| @@ -33,9 +34,9 @@ main(int argc, char * argv[]) | @@ -33,9 +34,9 @@ main(int argc, char * argv[]) | ||
| 33 | 34 | ||
| 34 | delete(hash); | 35 | delete(hash); |
| 35 | 36 | ||
| 36 | - hash = newFromJson( | ||
| 37 | - BIGPOINT_HASH, | ||
| 38 | - json_tokener_parse("{\"key1\":123,\"key2\":321}")); | 37 | + json = json_tokener_parse("{\"key1\":123,\"key2\":321}"); |
| 38 | + hash = newFromJson(BIGPOINT_HASH, json); | ||
| 39 | + json_object_put(json); | ||
| 39 | 40 | ||
| 40 | dyn = bigpoint_hash_get(hash, TEST_KEY1); | 41 | dyn = bigpoint_hash_get(hash, TEST_KEY1); |
| 41 | printf("%d\n", (dyn->data)._int); | 42 | printf("%d\n", (dyn->data)._int); |
Please
register
or
login
to post a comment