Open topic with navigation

TIBCO® Patterns 6.1.2

# The lpar_find_lst_lpar Function

There is still another way of accessing items in a list lpar. You can call the function `lpar_find_lst_lpar` with a specific lpar id, and the function return the lpar in the list that has that id, or the value `LPAR_NULL` if such an lpar was not found.

Note: If there is more than one lpar in a list with the same id, `lpar_find_lst_lpar` returns the last instance of that id in the list.

This is especially convenient when only some lpars in a list (for example, a list of statistics) are of interest to you. The loop that accessed the stats list in our example could be replaced with these four lines:

    lpar = lpar_find_lst_lpar(stats, LPAR_INT_MATCHESRET);
    printf("%d matching records\n", lpar_get_int(lpar));
    lpar = lpar_find_lst_lpar(stats, LPAR_DBL_SEARCHTIME);
    printf("Lookup took %.2f seconds\n", lpar_get_dbl(lpar));

We chose not to test the return value against `LPAR_NULL`, since the stats list returned by `lkt_dbsearch` (in the non-error case) always contains these lpars.

The lpar returned by `lpar_find_lst_lpar` is not a copy of the list lpar, it is the same lpar, using the same memory, as the lpar in the list. That means that this lpar must not be destroyed with `lpar_destroy`. It is automatically destroyed when the list is destroyed. This also means that any lpar returned by `lpar_find_lst_lpar` must not be used after the associated list is destroyed.

Did you find this helpful?

Yes No
Great!
Thanks for taking the time to give us some feedback.
Sorry about that

Why wasn't this helpful? (check all that apply)

Could not find what I was looking for
Instructions confusing or unclear
Instructions did not work

Want to tell us more?

Please select at least one option or provide details about the issue!!

Error occurred while submitting feedback.

Error2 occurred while submitting feedback.

TIBCO® Patterns

Copyright © 2010-2025. Cloud Software Group, Inc. All Rights Reserved.