fix mem management in load_save unit
Haldean Brown
6 years ago
69 | 69 | |
70 | 70 | v = calloc(1, sizeof(struct xl_value)); |
71 | 71 | assert(xl_value_load(v, &s) == OK); |
72 | assert(xl_take(v) == OK); | |
72 | 73 | |
73 | 74 | /* make sure tags are correct. */ |
74 | 75 | assert(v->tag == u[0].tag); |
78 | 79 | assert(v->right.t->left.t->right.t->tag == u[4].tag); |
79 | 80 | assert(v->right.t->left.t->left.t->left.t->tag == u[5].tag); |
80 | 81 | |
81 | /* make sure refcounts are all 1 except the root, which is not taken. */ | |
82 | assert(v->refcount == 0); | |
82 | /* make sure refcounts are all 1 except the root. */ | |
83 | assert(v->refcount == 1); | |
83 | 84 | assert(v->right.t->refcount == 1); |
84 | 85 | assert(v->right.t->left.t->refcount == 1); |
85 | 86 | assert(v->right.t->left.t->left.t->refcount == 1); |
108 | 109 | |
109 | 110 | xl_stream_close(&s); |
110 | 111 | free(u); |
111 | free(v); | |
112 | assert(xl_release(v) == OK); | |
112 | 113 | |
113 | 114 | return ok; |
114 | 115 | } |