Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

c-list: add c_list_init() #1

Merged
merged 1 commit into from
May 6, 2017
Merged

c-list: add c_list_init() #1

merged 1 commit into from
May 6, 2017

Conversation

thom311
Copy link
Contributor

@thom311 thom311 commented May 6, 2017

Add c_list_init() to initialize a CList instance.
For example:

c_list_init(&obj->list);

as a shorthand for the form

obj->list = (CList)C_LIST_INIT(&obj->list);

Is this left out intentionally to keep the API small? IMHO this short-hand would be nice, as the alternative is rather verbose.
Maybe return "void"? Dunno.

@dvdhrm
Copy link
Member

dvdhrm commented May 6, 2017

I usually prefer the direct assignment, but we always provide initializer as well. Looks like an oversight here.

Anyway, I'd make it return void and not allow NULL. Hence, just:

static inline void c_list_init(CList *list) {
        *list = (CList)C_LIST_INIT(*list);
}

Or is there a use-case to return the pointer?

@thom311
Copy link
Contributor Author

thom311 commented May 6, 2017

Anyway, I'd make it return void and not allow NULL. Hence, just:

Sure.

Or is there a use-case to return the pointer?

No strong use-case. Chaining of calls, which probably ends up in ugly code anyway.

Add c_list_init() to initialize a CList instance.
For example:

    c_list_init(&obj->list);

as a shorthand for the form

    obj->list = (CList)C_LIST_INIT(obj->list);

Signed-off-by: Thomas Haller <thaller@redhat.com>
@dvdhrm
Copy link
Member

dvdhrm commented May 6, 2017

Looks good! Thanks!

@dvdhrm dvdhrm merged commit b1b07b4 into c-util:master May 6, 2017
@thom311 thom311 deleted the c_list_init branch May 6, 2017 16:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants