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

Provide a code example for the info list #505

Open
abouteiller opened this issue Jan 25, 2024 · 0 comments
Open

Provide a code example for the info list #505

abouteiller opened this issue Jan 25, 2024 · 0 comments

Comments

@abouteiller
Copy link
Contributor

While working on #492, we thought that adding an example on how to use lists could be valuable.

@rhc54 proposed the following example

           I believe you asked me to provide a code example for the info list - here is a typical usage:
void *head;
pmix_status_t rc;
pmix_data_array_t darray;
pmix_info_t *info;
size_t ninfo;

// initialize the list
head = PMIx_Info_list_start();

// add something to the end of the list
rc = PMIx_Info_list_add(head, PMIX_CONNECT_TO_SYSTEM, NULL, PMIX_BOOL);
if (PMIX_SUCCESS != rc) {
    PMIx_Info_list_release(head);
    return rc;
}

// prepend something to the list
rc = PMIx_Info_list_prepend(head, PMIX_TCP_REPORT_URI, "filename", PMIX_STRING);
if (PMIX_SUCCESS != rc) {
    PMIx_Info_list_release(head);
    return rc;
}

// convert the list to an array of info
rc = PMIx_Info_list_convert(head, &darray);
if (PMIX_SUCCESS != rc) {
    PMIx_Info_list_release(head);
    return rc;
}

// cleanup the list
PMIx_Info_list_release(head);

// define pointer to the array of info for use
info = (pmix_info_t*)darray.array;
ninfo = darray.size;

Doesn't cover all the APIs - but is this sufficient? I could expand to cover more APIs, but this really is the most common usage.

Originally posted by @rhc54 in #492 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant