X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=test%2Ftest_shared_ptr.c;h=3502238a5f17f1a9611556bc8d9f0f39704db0b5;hb=f6def128a97444384d6c0939eaa04fb0e931d6df;hp=cff3ee0b52001222102959579381806d0d069263;hpb=24a138f8cd6c4c2c47d5c8d9b8efd7b19173b600;p=yaz-moved-to-github.git diff --git a/test/test_shared_ptr.c b/test/test_shared_ptr.c index cff3ee0..3502238 100644 --- a/test/test_shared_ptr.c +++ b/test/test_shared_ptr.c @@ -16,46 +16,10 @@ #include #include -#include +#include #include #include -#define YAZ_SHPTR_TYPE(type) \ - struct type##_shptr \ - { \ - type ptr; \ - int ref; \ - YAZ_MUTEX mutex; \ - }; \ - typedef struct type##_shptr *type##_shptr_t; - -#define YAZ_SHPTR_INIT(p,n) { \ - p = xmalloc(sizeof(*p)); \ - p->ptr = n; \ - p->ref = 1; \ - p->mutex = 0; \ - yaz_mutex_create(&p->mutex); \ - } - -#define YAZ_SHPTR_INC(p) { \ - yaz_mutex_enter(p->mutex); \ - p->ref++; \ - yaz_mutex_leave(p->mutex); \ - } - -#define YAZ_SHPTR_DEC(p, destroy) { \ - yaz_mutex_enter(p->mutex); \ - if (--p->ref == 0) { \ - yaz_mutex_leave(p->mutex); \ - destroy(p->ptr); \ - yaz_mutex_destroy(&p->mutex); \ - xfree(p); \ - p = 0; \ - } else { \ - yaz_mutex_leave(p->mutex); \ - } \ - } - YAZ_SHPTR_TYPE(WRBUF) static void test(void)