int main(int argc, char **argv) { list_t *mylist; int i, find, *temp; mylist = make_empty_list(); for(i=0; i < 100; i++) { temp = malloc(sizeof(int)); *temp = i; insert_at_foot(mylist, temp); } printf("Find what value?: "); scanf("%d", &find); if (is_list_element(mylist, &find)) { printf("Found.\n"); } else { printf("Not Found.\n"); } printlist(mylist); return 0; }
int32_t event_subscribe(struct event *const event, const event_id_t id, event_cb_t cb) { /* get byte and bit number of the given event in the event mask */ const uint8_t position = id >> 3; const uint8_t mask = 1 << (id & 0x7); ASSERT(event && cb && (id < EVENT_MAX_AMOUNT)); if (event->mask[position] & mask) { return ERR_NO_CHANGE; /* Already subscribed */ } if (!is_list_element(&events, event)) { memset(event->mask, 0, EVENT_MASK_SIZE); list_insert_as_head(&events, event); } event->cb = cb; event->mask[position] |= mask; subscribed[position] |= mask; return ERR_NONE; }