summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2012-05-25 16:51:38 +0200
committerJérémy Zurcher <jeremy@asynk.ch>2012-05-25 16:51:38 +0200
commit6f22eec5d62d0d6c57ab2e5e257ca907ee77125b (patch)
treedd02f46db254c7c48cc42e14f7d343fdff16ec59
parent51880aee4ed5ec9c40660bfb4640eb5fe695a62a (diff)
downloadedoors-6f22eec5d62d0d6c57ab2e5e257ca907ee77125b.zip
edoors-6f22eec5d62d0d6c57ab2e5e257ca907ee77125b.tar.gz
Particle: implement eiotas_particle_alloc and eiotas_particle_free
-rw-r--r--src/lib/eiotas_particle.c25
1 files changed, 24 insertions, 1 deletions
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);
}