diff options
Diffstat (limited to 'src/geometry/geometry.c')
-rw-r--r-- | src/geometry/geometry.c | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/src/geometry/geometry.c b/src/geometry/geometry.c index 42e7970..2405ae9 100644 --- a/src/geometry/geometry.c +++ b/src/geometry/geometry.c @@ -42,6 +42,12 @@ int kai_read_float_array(struct ka_float_array_t *dest, struct kai_tag_t *src) return 0; } +void kai_release_float_array(struct ka_float_array_t fa) +{ + free(fa.id); + free(fa.buf); +} + int kai_read_param(struct ka_param_t *dest, struct kai_tag_t *src) { @@ -60,6 +66,14 @@ int kai_read_param(struct ka_param_t *dest, struct kai_tag_t *src) return 0; } +void kai_release_param(struct ka_param_t p) +{ + free(p.name); + free(p.sid); + free(p.type); + free(p.semantic); +} + int kai_read_accessor(struct ka_accessor_t *dest, struct kai_tag_t *src) { @@ -99,6 +113,16 @@ int kai_read_accessor(struct ka_accessor_t *dest, struct kai_tag_t *src) return 0; } +void kai_release_accessor(struct ka_accessor_t a) +{ + free(a.source); + int i; + for (i=0; i<a.param_count; i++) { + kai_release_param(a.param[i]); + } + free(a.param); +} + int kai_read_source(struct ka_source_t *dest, struct kai_tag_t *src) { @@ -107,5 +131,28 @@ int kai_read_source(struct ka_source_t *dest, struct kai_tag_t *src) char *id = kai_tag_attr_to_dup(src, "id"); if (id == NULL) { return -1; } + dest->id = id; + dest->name = kai_tag_attr_to_dup(src, "name"); + + struct kai_tag_t *child; + for (child = src->children; child != NULL; child = child->next) { + if (strcmp(child->type, "float_array") == 0) { + kai_read_float_array(&(dest->float_array), child); + } + else if (strcmp(child->type, "technique_common") == 0) { + kai_read_accessor(&(dest->accessor), child->children); + } + /* ignore others */ + } + return 0; } + +void kai_release_source(struct ka_source_t s) +{ + free(s.id); + free(s.name); + + kai_release_float_array(s.float_array); + kai_release_accessor(s.accessor); +} |