Mercurial > lbo > hg > ylisp
view src/base/ptr_test.c @ 185:db386ec98dc3
base/ptr: Add yptr_rc_t implementation
author | Lewin Bormann <lbo@spheniscida.de> |
---|---|
date | Sun, 29 Sep 2019 14:42:18 +0200 |
parents | |
children |
line wrap: on
line source
#include "ptr.h" #include <assert.h> void test_ptr_rcptr_basic(void) { char* somestring = calloc(16, 1); yptr_rc_t ptr = YPTR_RC(somestring, NULL); assert(1 == yptr_rc_refs(ptr)); yptr_rc_t ptr2 = yptr_rc_clone(ptr); assert(2 == yptr_rc_refs(ptr)); yptr_rc_delete(ptr2); assert(1 == yptr_rc_refs(ptr)); yptr_rc_delete(ptr); } int main(void) { test_ptr_rcptr_basic(); return 0; }