Name
ec_bag_find — Find something in the specified bag
Synopsis
#include "ec_boh.h"
| void * **ec_bag_find** (
| bag, | |
| | typedname)
; | |
Description
Find something in the specified bag. The default behavior is to attempt to find the type, and then attempt to locate the type within other types, provided that the original type is known.
The second parameter may look redundant, but since we're dealing with void pointers, it allows us a sanity check that the type we are returning is still correct in cases where the type of a structure member changes. For example:
struct foo { email_message *message; };
Suppose the preceding code was changed to:
struct foo {
ec_message *message;
};
void *m = foo->message;
This code will compile happily and return us something when asked for a message, but that something will not be what we were looking for. For this reason, we assign to a typed local variable first before returning so that the compiler will warn us about changes of this kind.
- bag
-
The bag we are looking in.
- typedname
-
The data type that we are looking for.
This function returns a void pointer to the named data type.
It is legal to call this function in any thread.