From 0a233ef23e8c6209a532eed6fecceb01e7a9c3c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Fri, 25 May 2012 16:52:43 +0200 Subject: Particle: define and implement eiotas_particle _reset, _init, _merge --- src/include/eiotas_particle.h | 6 ++++++ src/lib/eiotas_particle.c | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/src/include/eiotas_particle.h b/src/include/eiotas_particle.h index 1b309a0..4ebe415 100644 --- a/src/include/eiotas_particle.h +++ b/src/include/eiotas_particle.h @@ -45,4 +45,10 @@ void eiotas_particle_free(Eiotas_Particle *particle); Eiotas_Particle* eiotas_particle_alloc(); +EAPI void eiotas_particle_reset(Eiotas_Particle *particle); + +EAPI void eiotas_particle_init(Eiotas_Particle *particle, Eiotas_Iota *iota); + +EAPI void eiotas_particle_merge(Eiotas_Particle *particle, Eiotas_Particle *p); + #endif // __EIOTAS_PARTICLE_H__ diff --git a/src/lib/eiotas_particle.c b/src/lib/eiotas_particle.c index 079caf1..4927e90 100644 --- a/src/lib/eiotas_particle.c +++ b/src/lib/eiotas_particle.c @@ -56,3 +56,36 @@ void eiotas_particle_free(Eiotas_Particle *particle) free(particle); } +EAPI void eiotas_particle_reset(Eiotas_Particle *particle) +{ + unsigned int i; + char *s; + Eiotas_Particle *p; + Eina_Inlist *li; + Eina_Array_Iterator it; + + particle->ts = 0; + particle->src = NULL; + particle->dst = NULL; + EINA_ARRAY_ITER_NEXT(particle->dsts, i, s, it) free(s); + eina_array_clean(particle->dsts); + eina_hash_free_buckets(particle->payload); + EINA_INLIST_FOREACH_SAFE(particle->merged, li, p) eiotas_particle_free(p); + particle->merged = NULL; + EINA_ARRAY_ITER_NEXT(particle->link_fields, i, s, it) free(s); + eina_array_clean(particle->link_fields); + if(particle->link_value) eina_stringshare_del(particle->link_value); + particle->link_value = NULL; +} + +EAPI void eiotas_particle_init(Eiotas_Particle *particle, Eiotas_Iota *iota) +{ + particle->src = iota; + particle->ts = time(NULL); +} + +EAPI void eiotas_particle_merge(Eiotas_Particle *particle, Eiotas_Particle *p) +{ + particle->merged = eina_inlist_append(particle->merged, EINA_INLIST_GET(p)); +} + -- cgit v1.1-2-g2b99