[PATCH v2 03/11] libtraceeval: Add traceeval_iterator_results_release()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: "Steven Rostedt (Google)" <rostedt@xxxxxxxxxxx>

Add the function that can release the results from the
traceeval_iterator_qeury() function.

Currently, the user must use traceeval_results_release() for the results
returned by traceeval_iterator_query(), but that requires the caller to
also have access to the traceeval where the iterator came from. There
could be many iterators and many traceevals, the user should not need to
worry about which one goes with which.

This new traceeval_iterator_results_release() will take care of that for
them.

Signed-off-by: Steven Rostedt (Google) <rostedt@xxxxxxxxxxx>
---
 include/traceeval-hist.h |  2 ++
 src/histograms.c         | 23 +++++++++++++++++++++++
 2 files changed, 25 insertions(+)

diff --git a/include/traceeval-hist.h b/include/traceeval-hist.h
index 837a74f61a66..80450d7ae7f9 100644
--- a/include/traceeval-hist.h
+++ b/include/traceeval-hist.h
@@ -188,5 +188,7 @@ int traceeval_iterator_next(struct traceeval_iterator *iter,
 			    const union traceeval_data **keys);
 int traceeval_iterator_query(struct traceeval_iterator *iter,
 			     const union traceeval_data **results);
+void traceeval_iterator_results_release(struct traceeval_iterator *iter,
+					const union traceeval_data *results);
 
 #endif /* __LIBTRACEEVAL_HIST_H__ */
diff --git a/src/histograms.c b/src/histograms.c
index 06613a8933ec..50dc8b689637 100644
--- a/src/histograms.c
+++ b/src/histograms.c
@@ -1336,3 +1336,26 @@ int traceeval_iterator_query(struct traceeval_iterator *iter,
 
 	return 1;
 }
+
+/*
+ * traceeval_iterator_results_release - release the results return by traceeval_iterator_query()
+ * @iter: The iterator descriptor used in traceeval_iterator_query()
+ * @results: The results returned by traceeval_iterator_query()
+ *
+ * The @results returned by traceeval_iterator_query() is owned by @teval,
+ * that is attached to the iterator and how it manages it is implementation
+ * specific. The caller should not worry about it. When the caller of
+ * traceeval_iterator_query() is done with the @results, it must call
+ * traceeval_iterator_results_release() (or traceeval_results_release() if it
+ * has the handle of the teval used to get the iterator) on it to allow traceeval
+ * to clean up its references.
+ */
+void traceeval_iterator_results_release(struct traceeval_iterator *iter,
+					const union traceeval_data *results)
+{
+	if (!iter || !results) {
+		if (!iter)
+			print_err("Results to be freed without accompanied iterator!");
+		return;
+	}
+}
-- 
2.40.1





[Index of Archives]     [Linux USB Development]     [Linux USB Development]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux