Refactoring: introduce lttng_tracker_ids data structure
[lttng-tools.git] / include / lttng / tracker.h
index 2d952a6e3f23488e5ca7253dcd14d821d96ad0fd..a66a2cfce4dea3701fd0cb53fe25329bdd12eb78 100644 (file)
@@ -51,6 +51,7 @@ enum lttng_tracker_id_status {
 
 struct lttng_handle;
 struct lttng_tracker_id;
+struct lttng_tracker_ids;
 
 /*
  * Create a tracker id for the passed tracker type.
@@ -132,12 +133,6 @@ extern enum lttng_tracker_id_status lttng_tracker_id_get_value(
 extern enum lttng_tracker_id_status lttng_tracker_id_get_string(
                const struct lttng_tracker_id *id, const char **value);
 
-/*
- * Destroys (frees) an array of tracker id.
- */
-extern void lttng_tracker_ids_destroy(
-               struct lttng_tracker_id **ids, size_t nr_ids);
-
 /*
  * Add ID to session tracker.
  *
@@ -165,17 +160,16 @@ extern int lttng_untrack_id(struct lttng_handle *handle,
  * List IDs in the tracker.
  *
  * tracker_type is the type of tracker.
- * ids is set to an allocated array of IDs currently tracked.
- * On success, ids must be freed using lttng_tracker_id_destroy on each
- * constituent of the returned array  or using lttng_tracker_ids_destroy.
- * nr_ids is set to the number of entries contained by the ids array.
+ * ids is set to an allocated lttng_tracker_ids representing IDs
+ * currently tracked.
+ * On success, caller is responsible for freeing ids
+ * using lttng_tracker_ids_destroy.
  *
  * Returns 0 on success, else a negative LTTng error code.
  */
 extern int lttng_list_tracker_ids(struct lttng_handle *handle,
                enum lttng_tracker_type tracker_type,
-               struct lttng_tracker_id ***ids,
-               size_t *nr_ids);
+               struct lttng_tracker_ids **ids);
 
 /*
  * Backward compatibility.
@@ -215,6 +209,28 @@ extern int lttng_list_tracker_pids(struct lttng_handle *handle,
                int32_t **pids,
                size_t *nr_pids);
 
+/*
+ * Get a tracker id from the list at a given index.
+ *
+ * Note that the list maintains the ownership of the returned tracker id.
+ * It must not be destroyed by the user, nor should it be held beyond the
+ * lifetime of the tracker id list.
+ *
+ * Returns a tracker id, or NULL on error.
+ */
+extern const struct lttng_tracker_id *lttng_tracker_ids_get_at_index(
+               const struct lttng_tracker_ids *ids, unsigned int index);
+
+/*
+ * Get the number of tracker id in a tracker id list.
+ */
+extern int lttng_tracker_ids_get_count(const struct lttng_tracker_ids *ids);
+
+/*
+ * Destroy a tracker id list.
+ */
+extern void lttng_tracker_ids_destroy(struct lttng_tracker_ids *ids);
+
 #ifdef __cplusplus
 }
 #endif
This page took 0.024236 seconds and 4 git commands to generate.