cs_error_t icmap_track_delete(icmap_track_t icmap_track) { int32_t err; if ((err = qb_map_notify_del_2(icmap_map, icmap_track->key_name, icmap_notify_fn, icmap_tt_to_qbtt(icmap_track->track_type), icmap_track)) != 0) { return (qb_to_cs_error(err)); } free(icmap_track->key_name); free(icmap_track); return (CS_OK); }
cs_error_t icmap_track_add( const char *key_name, int32_t track_type, icmap_notify_fn_t notify_fn, void *user_data, icmap_track_t *icmap_track) { int32_t err; if (notify_fn == NULL || icmap_track == NULL) { return (CS_ERR_INVALID_PARAM); } if ((track_type & ~(ICMAP_TRACK_ADD | ICMAP_TRACK_DELETE | ICMAP_TRACK_MODIFY | ICMAP_TRACK_PREFIX)) != 0) { return (CS_ERR_INVALID_PARAM); } *icmap_track = malloc(sizeof(**icmap_track)); if (*icmap_track == NULL) { return (CS_ERR_NO_MEMORY); } memset(*icmap_track, 0, sizeof(**icmap_track)); if (key_name != NULL) { (*icmap_track)->key_name = strdup(key_name); }; (*icmap_track)->track_type = track_type; (*icmap_track)->notify_fn = notify_fn; (*icmap_track)->user_data = user_data; if ((err = qb_map_notify_add(icmap_map, (*icmap_track)->key_name, icmap_notify_fn, icmap_tt_to_qbtt(track_type), *icmap_track)) != 0) { free((*icmap_track)->key_name); free(*icmap_track); return (qb_to_cs_error(err)); } list_init(&(*icmap_track)->list); list_add (&(*icmap_track)->list, &icmap_track_list_head); return (CS_OK); }