From 6f22eec5d62d0d6c57ab2e5e257ca907ee77125b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Fri, 25 May 2012 16:51:38 +0200 Subject: Particle: implement eiotas_particle_alloc and eiotas_particle_free --- src/lib/eiotas_particle.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/lib/eiotas_particle.c b/src/lib/eiotas_particle.c index 63b9a75..079caf1 100644 --- a/src/lib/eiotas_particle.c +++ b/src/lib/eiotas_particle.c @@ -21,15 +21,38 @@ Eiotas_Particle* eiotas_particle_alloc() { - Eiotas_Particle *particle = (Eiotas_Particle*)malloc(sizeof(Eiotas_Particle)); + BUILD_INSTANCE(Eiotas_Particle,particle); + + particle->ts = 0; + particle->src = NULL; + particle->dst = NULL; + particle->dsts = eina_array_new(EIOTAS_PARTICLE_ARRAY_STEP); + particle->payload = eina_hash_string_small_new(NULL); // TODO data delete function + particle->merged = NULL; + particle->link_fields = eina_array_new(EIOTAS_PARTICLE_ARRAY_STEP); + particle->link_value = NULL; return particle; } void eiotas_particle_free(Eiotas_Particle *particle) { + unsigned int i; + char *s; + Eiotas_Particle *p; + Eina_Inlist *li; + Eina_Array_Iterator it; + DBG("Particle free 0x%X",PRINTPTR(particle)); + EINA_ARRAY_ITER_NEXT(particle->dsts, i, s, it) free(s); + eina_array_free(particle->dsts); + eina_hash_free(particle->payload); + EINA_INLIST_FOREACH_SAFE(particle->merged, li, p) eiotas_particle_free(p); + EINA_ARRAY_ITER_NEXT(particle->link_fields, i, s, it) free(s); + eina_array_free(particle->link_fields); + if(particle->link_value) eina_stringshare_del(particle->link_value); + free(particle); } -- cgit v1.1-2-g2b99