forked from enlightenment/efl
parent
7d237bcf01
commit
515282006f
|
@ -289,7 +289,7 @@ eina_cow_del(Eina_Cow *cow)
|
|||
free(cow);
|
||||
}
|
||||
|
||||
EAPI const void *
|
||||
EAPI const Eina_Cow_Data *
|
||||
eina_cow_alloc(Eina_Cow *cow)
|
||||
{
|
||||
EINA_COW_MAGIC_CHECK(cow);
|
||||
|
@ -298,7 +298,7 @@ eina_cow_alloc(Eina_Cow *cow)
|
|||
}
|
||||
|
||||
EAPI void
|
||||
eina_cow_free(Eina_Cow *cow, const void *data)
|
||||
eina_cow_free(Eina_Cow *cow, const Eina_Cow_Data *data)
|
||||
{
|
||||
Eina_Cow_Ptr *ref;
|
||||
|
||||
|
@ -318,7 +318,8 @@ eina_cow_free(Eina_Cow *cow, const void *data)
|
|||
}
|
||||
|
||||
EAPI void *
|
||||
eina_cow_write(Eina_Cow *cow, const void * const *data)
|
||||
eina_cow_write(Eina_Cow *cow,
|
||||
const Eina_Cow_Data * const *data)
|
||||
{
|
||||
Eina_Cow_Ptr *ref;
|
||||
void *r;
|
||||
|
@ -360,7 +361,9 @@ eina_cow_write(Eina_Cow *cow, const void * const *data)
|
|||
}
|
||||
|
||||
EAPI void
|
||||
eina_cow_done(Eina_Cow *cow, const void * const * dst, const void *data)
|
||||
eina_cow_done(Eina_Cow *cow,
|
||||
const Eina_Cow_Data * const * dst,
|
||||
const void *data)
|
||||
{
|
||||
Eina_Cow_Ptr *ref;
|
||||
Eina_Cow_GC *gc;
|
||||
|
@ -385,7 +388,9 @@ eina_cow_done(Eina_Cow *cow, const void * const * dst, const void *data)
|
|||
}
|
||||
|
||||
EAPI void
|
||||
eina_cow_memcpy(Eina_Cow *cow, const void * const *dst, const void *src)
|
||||
eina_cow_memcpy(Eina_Cow *cow,
|
||||
const Eina_Cow_Data * const *dst,
|
||||
const Eina_Cow_Data *src)
|
||||
{
|
||||
Eina_Cow_Ptr *ref;
|
||||
|
||||
|
|
|
@ -20,16 +20,22 @@
|
|||
#define EINA_COW_H_
|
||||
|
||||
typedef struct _Eina_Cow Eina_Cow;
|
||||
typedef void Eina_Cow_Data;
|
||||
|
||||
EAPI Eina_Cow *eina_cow_add(const char *name, unsigned int struct_size, unsigned int step, const void *default_value) EINA_WARN_UNUSED_RESULT;
|
||||
EAPI void eina_cow_del(Eina_Cow *cow);
|
||||
|
||||
EAPI const void *eina_cow_alloc(Eina_Cow *cow) EINA_WARN_UNUSED_RESULT;
|
||||
EAPI void eina_cow_free(Eina_Cow *cow, const void *data);
|
||||
EAPI const Eina_Cow_Data *eina_cow_alloc(Eina_Cow *cow) EINA_WARN_UNUSED_RESULT;
|
||||
EAPI void eina_cow_free(Eina_Cow *cow, const Eina_Cow_Data *data);
|
||||
|
||||
EAPI void *eina_cow_write(Eina_Cow *cow, const void * const *src) EINA_WARN_UNUSED_RESULT;
|
||||
EAPI void eina_cow_done(Eina_Cow *cow, const void * const *dst, const void *data);
|
||||
EAPI void eina_cow_memcpy(Eina_Cow *cow, const void * const *dst, const void *src);
|
||||
EAPI void *eina_cow_write(Eina_Cow *cow,
|
||||
const Eina_Cow_Data * const *src) EINA_WARN_UNUSED_RESULT;
|
||||
EAPI void eina_cow_done(Eina_Cow *cow,
|
||||
const Eina_Cow_Data * const *dst,
|
||||
const void *data);
|
||||
EAPI void eina_cow_memcpy(Eina_Cow *cow,
|
||||
const Eina_Cow_Data * const *dst,
|
||||
const Eina_Cow_Data *src);
|
||||
|
||||
EAPI Eina_Bool eina_cow_gc(Eina_Cow *cow);
|
||||
|
||||
|
|
|
@ -56,22 +56,24 @@ START_TEST(eina_cow_bad)
|
|||
cur = eina_cow_alloc(cow);
|
||||
fail_if(cur == NULL);
|
||||
|
||||
write = eina_cow_write(cow, &cur);
|
||||
write = eina_cow_write(cow, (const Eina_Cow_Data**) &cur);
|
||||
fail_if(write == NULL || write == &default_value);
|
||||
|
||||
write->i = 7;
|
||||
eina_cow_done(cow, &cur, write);
|
||||
eina_cow_done(cow, (const Eina_Cow_Data**) &cur, write);
|
||||
fail_if(cur->i != 7 || default_value.i != 42);
|
||||
|
||||
eina_log_print_cb_set(_eina_test_log, &over_commit);
|
||||
eina_cow_done(cow, &cur, write); /* Testing over commit */
|
||||
/* Testing over commit */
|
||||
eina_cow_done(cow, (const Eina_Cow_Data**) &cur, write);
|
||||
fail_if(!over_commit);
|
||||
|
||||
write = eina_cow_write(cow, &cur);
|
||||
write = eina_cow_write(cow, (const Eina_Cow_Data**) &cur);
|
||||
fail_if(write == NULL || write == &default_value);
|
||||
|
||||
eina_log_print_cb_set(_eina_test_log, &over_writing);
|
||||
write = eina_cow_write(cow, &cur); /* Testing over writing */
|
||||
/* Testing over writing */
|
||||
write = eina_cow_write(cow, (const Eina_Cow_Data**) &cur);
|
||||
fail_if(write != NULL || !over_writing);
|
||||
|
||||
eina_cow_free(cow, cur);
|
||||
|
@ -95,22 +97,24 @@ START_TEST(eina_cow)
|
|||
cur = eina_cow_alloc(cow);
|
||||
fail_if(prev == NULL || cur == NULL);
|
||||
|
||||
write = eina_cow_write(cow, &cur);
|
||||
write = eina_cow_write(cow, (const Eina_Cow_Data**) &cur);
|
||||
fail_if(write == NULL || write == &default_value);
|
||||
|
||||
write->i = 7;
|
||||
eina_cow_done(cow, &cur, write);
|
||||
eina_cow_done(cow, (const Eina_Cow_Data**) &cur, write);
|
||||
fail_if(cur->i != 7 || prev->i != 0);
|
||||
|
||||
eina_cow_memcpy(cow, &prev, cur);
|
||||
eina_cow_memcpy(cow,
|
||||
(const Eina_Cow_Data**) &prev,
|
||||
(const Eina_Cow_Data*) cur);
|
||||
fail_if(cur->i != 7 || prev->i != 7);
|
||||
fail_if(default_value.i != 0);
|
||||
|
||||
write = eina_cow_write(cow, &cur);
|
||||
write = eina_cow_write(cow, (const Eina_Cow_Data**) &cur);
|
||||
fail_if(write == NULL || write == &default_value);
|
||||
|
||||
write->i = 42; write->c = 5;
|
||||
eina_cow_done(cow, &cur, write);
|
||||
eina_cow_done(cow, (const Eina_Cow_Data**) &cur, write);
|
||||
fail_if(cur->i != 42 || cur->c != 5 ||
|
||||
prev->i != 7 || prev->c != 42 ||
|
||||
default_value.c != 42 || default_value.i != 0);
|
||||
|
@ -118,15 +122,15 @@ START_TEST(eina_cow)
|
|||
fail_if(eina_cow_gc(cow) == EINA_FALSE);
|
||||
fail_if(eina_cow_gc(cow) == EINA_FALSE);
|
||||
|
||||
write = eina_cow_write(cow, &cur);
|
||||
write = eina_cow_write(cow, (const Eina_Cow_Data**) &cur);
|
||||
write->i = 7; write->c = 42;
|
||||
eina_cow_done(cow, &cur, write);
|
||||
eina_cow_done(cow, (const Eina_Cow_Data**) &cur, write);
|
||||
|
||||
fail_if(eina_cow_gc(cow) == EINA_FALSE);
|
||||
fail_if(cur != prev);
|
||||
|
||||
eina_cow_free(cow, cur);
|
||||
eina_cow_free(cow, prev);
|
||||
eina_cow_free(cow, (const Eina_Cow_Data*) cur);
|
||||
eina_cow_free(cow, (const Eina_Cow_Data*) prev);
|
||||
|
||||
eina_cow_del(cow);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue