Commit ac539ffa2aad055d01d374bd51a11f104277aad7

Authored by Georg Hopp
1 parent a9ecc666

small fixes and preparations for further additions. valgrind shows no leaks now

... ... @@ -4,6 +4,7 @@
4 4 #include <json/json.h>
5 5
6 6 #include "bigpoint_dyntype.h"
  7 +#include "bigpoint_hash.h"
7 8
8 9
9 10 static
... ... @@ -24,10 +25,11 @@ __construct(struct BIGPOINT_DYNTYPE * _this, va_list * params)
24 25 break;
25 26
26 27 case BIGPOINT_DYNTYPE_HASH:
  28 + (_this->data)._hash = new(BIGPOINT_HASH);
27 29 break;
28 30
29 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 59 default:
58 60 _this->type = BIGPOINT_DYNTYPE_NULL;
59 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 5
6 6 #include "bigpoint_cclass.h"
7 7
  8 +struct BIGPOINT_DYNTYPE;
  9 +
  10 +#include "bigpoint_hash.h"
  11 +
8 12
9 13 enum BIGPOINT_DYNTYPE_TYPES {
10 14 BIGPOINT_DYNTYPE_NULL = 0,
... ... @@ -26,7 +30,8 @@ struct BIGPOINT_DYNTYPE {
26 30 int _int;
27 31 double _float;
28 32 char * _string;
29   - void * _object;
  33 + struct BIGPOINT_DYNTYPE ** _array;
  34 + struct BIGPOINT_HASH * _hash;
30 35 } data;
31 36 };
32 37
... ...
... ... @@ -16,6 +16,7 @@ main(int argc, char * argv[])
16 16 {
17 17 struct BIGPOINT_DYNTYPE * dyn;
18 18 struct BIGPOINT_HASH * hash = new(BIGPOINT_HASH);
  19 + struct json_object * json;
19 20
20 21 dyn = new(BIGPOINT_DYNTYPE, BIGPOINT_DYNTYPE_INT, sizeof(int), 123);
21 22 bigpoint_hash_set(hash, TEST_KEY1, dyn);
... ... @@ -33,9 +34,9 @@ main(int argc, char * argv[])
33 34
34 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 41 dyn = bigpoint_hash_get(hash, TEST_KEY1);
41 42 printf("%d\n", (dyn->data)._int);
... ...
Please register or login to post a comment