mirror of
https://git.notmuchmail.org/git/notmuch
synced 2024-11-24 20:08:10 +01:00
Add destroy functions for results, message, and tags.
None of these are strictly necessary, (everything was leak-free without them), but notmuch_message_destroy can actually be useful for when one query has many message results, but only one is needed to be live at a time. The destroy functions for results and tags are fairly gratuitous, as there's unlikely to be any benefit from calling them. But they're all easy to add, (all of these functions are just wrappers for talloc_free), and we do so for consistency and completeness.
This commit is contained in:
parent
f6c7810945
commit
4ca1492f1b
3 changed files with 58 additions and 4 deletions
12
message.cc
12
message.cc
|
@ -115,6 +115,12 @@ notmuch_message_get_tags (notmuch_message_t *message)
|
||||||
return tags;
|
return tags;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
notmuch_message_destroy (notmuch_message_t *message)
|
||||||
|
{
|
||||||
|
talloc_free (message);
|
||||||
|
}
|
||||||
|
|
||||||
notmuch_bool_t
|
notmuch_bool_t
|
||||||
notmuch_tags_has_more (notmuch_tags_t *tags)
|
notmuch_tags_has_more (notmuch_tags_t *tags)
|
||||||
{
|
{
|
||||||
|
@ -141,3 +147,9 @@ notmuch_tags_advance (notmuch_tags_t *tags)
|
||||||
{
|
{
|
||||||
tags->iterator++;
|
tags->iterator++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
notmuch_tags_destroy (notmuch_tags_t *tags)
|
||||||
|
{
|
||||||
|
talloc_free (tags);
|
||||||
|
}
|
||||||
|
|
44
notmuch.h
44
notmuch.h
|
@ -226,8 +226,13 @@ notmuch_query_set_sort (notmuch_query_t *query, notmuch_sort_t sort);
|
||||||
*
|
*
|
||||||
* notmuch_query_destroy (query);
|
* notmuch_query_destroy (query);
|
||||||
*
|
*
|
||||||
* Note that there's no explicit destructor for the notmuch_results_t
|
* Note that there's no explicit destructor needed for the
|
||||||
* object.
|
* notmuch_results_t object.
|
||||||
|
*
|
||||||
|
* (For consistency, we do provide a notmuch_results_destroy function,
|
||||||
|
* but there's no point in calling it if you're about to destroy the
|
||||||
|
* query object as well too---either call will free all the memory of
|
||||||
|
* the results).
|
||||||
*/
|
*/
|
||||||
notmuch_results_t *
|
notmuch_results_t *
|
||||||
notmuch_query_search (notmuch_query_t *query);
|
notmuch_query_search (notmuch_query_t *query);
|
||||||
|
@ -272,6 +277,15 @@ notmuch_results_get (notmuch_results_t *results);
|
||||||
void
|
void
|
||||||
notmuch_results_advance (notmuch_results_t *results);
|
notmuch_results_advance (notmuch_results_t *results);
|
||||||
|
|
||||||
|
/* Destroy a notmuch_results_t object.
|
||||||
|
*
|
||||||
|
* It's not strictly necessary to call this function. All memory from
|
||||||
|
* the notmuch_results_t object will be reclaimed when the containg
|
||||||
|
* query object is destroyed.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
notmuch_results_destroy (notmuch_results_t *results);
|
||||||
|
|
||||||
/* Get the message ID of 'message'.
|
/* Get the message ID of 'message'.
|
||||||
*
|
*
|
||||||
* The returned string belongs to 'message' and as such, should not be
|
* The returned string belongs to 'message' and as such, should not be
|
||||||
|
@ -305,12 +319,25 @@ notmuch_message_get_message_id (notmuch_message_t *message);
|
||||||
* ....
|
* ....
|
||||||
* }
|
* }
|
||||||
*
|
*
|
||||||
* Note that there's no explicit destructor for the notmuch_tags_t
|
* Note: If you are finished with a message before its containing
|
||||||
* object.
|
* query, you can call notmuch_message_destroy to clean up some memory
|
||||||
|
* sooner. If you don't call it, all the memory will still be
|
||||||
|
* reclaimed when the query is destroyed.
|
||||||
*/
|
*/
|
||||||
notmuch_tags_t *
|
notmuch_tags_t *
|
||||||
notmuch_message_get_tags (notmuch_message_t *message);
|
notmuch_message_get_tags (notmuch_message_t *message);
|
||||||
|
|
||||||
|
/* Destroy a notmuch_message_t object.
|
||||||
|
*
|
||||||
|
* It can be useful to call this function in the case of a single
|
||||||
|
* query object with many messages in the result, (such as iterating
|
||||||
|
* over the entire database). Otherwise, it's fine to never call this
|
||||||
|
* function and there will still be no memory leaks. (The memory from
|
||||||
|
* the messages get reclaimed when the containing query is destroyed.)
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
notmuch_message_destroy (notmuch_message_t *message);
|
||||||
|
|
||||||
/* Does the given notmuch_tags_t object contain any more results.
|
/* Does the given notmuch_tags_t object contain any more results.
|
||||||
*
|
*
|
||||||
* When this function returns TRUE, notmuch_tags_get will return a
|
* When this function returns TRUE, notmuch_tags_get will return a
|
||||||
|
@ -342,6 +369,15 @@ notmuch_tags_get (notmuch_tags_t *tags);
|
||||||
void
|
void
|
||||||
notmuch_tags_advance (notmuch_tags_t *results);
|
notmuch_tags_advance (notmuch_tags_t *results);
|
||||||
|
|
||||||
|
/* Destroy a notmuch_tags_t object.
|
||||||
|
*
|
||||||
|
* It's not strictly necessary to call this function. All memory from
|
||||||
|
* the notmuch_tags_t object will be reclaimed when the containg
|
||||||
|
* message or query objects are destroyed.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
notmuch_tags_destroy (notmuch_tags_t *tags);
|
||||||
|
|
||||||
NOTMUCH_END_DECLS
|
NOTMUCH_END_DECLS
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
6
query.cc
6
query.cc
|
@ -141,3 +141,9 @@ notmuch_results_advance (notmuch_results_t *results)
|
||||||
{
|
{
|
||||||
results->iterator++;
|
results->iterator++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
notmuch_results_destroy (notmuch_results_t *results)
|
||||||
|
{
|
||||||
|
talloc_free (results);
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue