diff options
author | Felix Fietkau <nbd@nbd.name> | 2023-01-04 14:12:43 +0100 |
---|---|---|
committer | Felix Fietkau <nbd@nbd.name> | 2023-01-06 13:17:42 +0100 |
commit | c0e413c21f7b114a70282041a0049196869dd15f (patch) | |
tree | e19993595113ae8bba777278ecceabfc1ef0201e /types.c | |
parent | ff32355ea6455a59f769f96fdeee7dd055f40e50 (diff) |
include: add uc_fn_thisval()
Can be used to get rid of a layer of pointer indirection in resource type
handlers.
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Diffstat (limited to 'types.c')
-rw-r--r-- | types.c | 22 |
1 files changed, 19 insertions, 3 deletions
@@ -1096,8 +1096,8 @@ ucv_resource_new(uc_resource_type_t *type, void *data) return &res->header; } -void ** -ucv_resource_dataptr(uc_value_t *uv, const char *name) +static uc_resource_t * +ucv_resource_check(uc_value_t *uv, const char *name) { uc_resource_t *res = (uc_resource_t *)uv; @@ -1109,7 +1109,23 @@ ucv_resource_dataptr(uc_value_t *uv, const char *name) return NULL; } - return &res->data; + return res; +} + +void * +ucv_resource_data(uc_value_t *uv, const char *name) +{ + uc_resource_t *res = ucv_resource_check(uv, name); + + return res ? res->data : NULL; +} + +void ** +ucv_resource_dataptr(uc_value_t *uv, const char *name) +{ + uc_resource_t *res = ucv_resource_check(uv, name); + + return res ? &res->data : NULL; } |