From: Elias Fleckenstein Date: Sun, 3 Apr 2022 20:13:18 +0000 (+0200) Subject: Add refcount_obj X-Git-Url: https://git.lizzy.rs/?a=commitdiff_plain;h=7acf5c46c8145a8c7318fa9babd19e6432d9803a;p=dragonstd.git Add refcount_obj --- diff --git a/refcount.c b/refcount.c index f7a43ac..e0b354c 100644 --- a/refcount.c +++ b/refcount.c @@ -25,7 +25,7 @@ void *refcount_inc(void *refcount) void *refcount_grb(void *refcount) { - return ((Refcount *) refcount_inc(refcount))->obj; + return refcount_obj(refcount_inc(refcount)); } void *refcount_drp(void *refcount) @@ -41,3 +41,8 @@ void *refcount_drp(void *refcount) return rc->obj; } + +void *refcount_obj(void *refcount) +{ + return ((Refcount *) refcount)->obj; +} diff --git a/refcount.h b/refcount.h index 32904f5..12e99d3 100644 --- a/refcount.h +++ b/refcount.h @@ -72,4 +72,12 @@ void *refcount_drp(void *refcount); otherwise. */ +void *refcount_obj(void *refcount) +/* + [Thread Safe] + Return referenced object. + This actually takes a Refcount * as argument, however void * is used to make it more + convenient to use the function as callback. +*/ + #endif // _DRAGONSTD_REFCOUNT_H_