Commit c65c24a7 authored by Petr Machata's avatar Petr Machata

Extract the logic for creating void* type to type_get_voidptr

parent a186b0e5
......@@ -645,12 +645,10 @@ void
init_global_config(void)
{
protolib_init(&legacy_typedefs);
struct arg_type_info *void_info = type_get_simple(ARGTYPE_VOID);
static struct arg_type_info ptr_info;
type_init_pointer(&ptr_info, void_info, 0);
struct arg_type_info *ptr_info = type_get_voidptr();
static struct named_type voidptr_type;
named_type_init(&voidptr_type, &ptr_info, 0);
named_type_init(&voidptr_type, ptr_info, 0);
/* Build legacy typedefs first. This is used by
* protolib_cache_init call below. */
......
......@@ -59,6 +59,19 @@ type_get_simple(enum arg_type type)
abort();
}
struct arg_type_info *
type_get_voidptr(void)
{
struct arg_type_info *void_info = type_get_simple(ARGTYPE_VOID);
static struct arg_type_info *ret;
if (ret == NULL) {
static struct arg_type_info ptr_info;
type_init_pointer(&ptr_info, void_info, 0);
ret = &ptr_info;
}
return ret;
}
static void
type_init_common(struct arg_type_info *info, enum arg_type type)
{
......
......@@ -70,6 +70,7 @@ struct arg_type_info {
* struct, or pointer. Each call with the same TYPE yields the same
* arg_type_info pointer. */
struct arg_type_info *type_get_simple(enum arg_type type);
struct arg_type_info *type_get_voidptr(void);
/* Initialize INFO so it becomes ARGTYPE_STRUCT. The created
* structure contains no fields. Use type_struct_add to populate the
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment