Add initial stuff
This commit is contained in:
1 parent
2d8bda0fe0
commit
8e9d20ba1a
45 files changed
+8901
No files matched your search
@@ -0,0 +1,59 @@
|
||||
#include <assert.h>
|
||||
|
||||
#include "m-shared.h"
|
||||
|
||||
SHARED_PTR_DEF(int, int)
|
||||
|
||||
#include <gmp.h>
|
||||
|
||||
SHARED_PTR_DEF(mpz, mpz_t, (CLEAR(mpz_clear)))
|
||||
|
||||
static int f(const shared_int_t p)
|
||||
{
|
||||
return *shared_int_cref(p);
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
shared_int_t p1, p2;
|
||||
|
||||
shared_int_init2(p1, malloc(sizeof(int)));
|
||||
assert(shared_int_ref(p1) != NULL);
|
||||
|
||||
*shared_int_ref(p1) = 12;
|
||||
|
||||
shared_int_init_set(p2, p1);
|
||||
assert(f(p2) == 12);
|
||||
|
||||
shared_int_release(p1);
|
||||
assert(shared_int_NULL_p(p1));
|
||||
assert(f(p2) == 12);
|
||||
|
||||
shared_int_set(p1, p2);
|
||||
|
||||
shared_int_release(p2);
|
||||
assert(shared_int_NULL_p(p2));
|
||||
|
||||
assert(f(p1) == 12);
|
||||
shared_int_set(p2, p1);
|
||||
assert(f(p2) == 12);
|
||||
|
||||
shared_int_release(p2);
|
||||
shared_int_release(p1);
|
||||
|
||||
assert(shared_int_NULL_p(p1));
|
||||
assert(shared_int_NULL_p(p2));
|
||||
|
||||
shared_int_clear(p2);
|
||||
shared_int_clear(p1);
|
||||
|
||||
shared_int_init2(p1, NULL);
|
||||
assert(shared_int_NULL_p(p1));
|
||||
shared_int_clear(p1);
|
||||
|
||||
shared_int_init(p1);
|
||||
assert(shared_int_NULL_p(p1));
|
||||
shared_int_clear(p1);
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in new issue
Block a user