aboutsummaryrefslogtreecommitdiffhomepage
path: root/message.cc
Commit message (Collapse)AuthorAge
*-. Merge branch from fixing up bugs after bisecting.Gravatar Carl Worth2009-10-21
|\ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | I'm glad that when I implemented "notmuch restore" I went through the extra effort to take the code I had written in one sitting into over a dozen commits. Sure enough, I hadn't tested well enough and had totally broken "notmuch setup", (segfaults and bogus thread_id values). With the little commits I had made, git bisect saved the day, and I went back to make the fixes right on top of the commits that introduced the bugs. So now we octopus merge those in.
| * | Fix lifetime-maintenance bug with std::string and c_str()Gravatar Carl Worth2009-10-21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Here's more evidence that C++ is a nightmare to program---or that I'm smart enough to realize that C++ is more clever than I will ever be. Most of my issues with C++ have to do with it hiding things from me that I'd really like to and expect to be aware of as a C programmer. For example, the specific problem here is that there's a short-lived std::string, from which I just want to copy the C string. I try to do that on the next line, but before I can, C++ has already called the destructor on the std::string. Now, C++ isn't alone in doing garbage collecting like this. But in a *real* garbage-collecting system, everything would work that way. For example, here, I'm still holding a pointer to the C string contents, so if the garbage collector were aware of that reference, then it might clean up the std::string container and leave the data I'm still using. But that's not what we get with C++. Instead, some things are reference counted and collected, (like the std::string), and some things just aren't (like the C string it contains). The end result is that it's very fragile. It forces me to be aware of the timing of hidden functions. In a "real" system I wouldn't have to be aware of that timing, and in C the function just wouldn't be hidden.
* | | Add notmuch_message_add_tag and notmuch_message_remove_tagGravatar Carl Worth2009-10-21
| | | | | | | | | | | | | | | With these two added, we now have enough functionality in the library to implement "notmuch restore".
* | | notmuch_message_get_message_id: Fix to cache resultGravatar Carl Worth2009-10-21
| |/ |/| | | | | | | | | | | | | | | Previously, this would allocate new memory with every call. That was with talloc, of course, so there wasn't any leaking (eventually). But since we're now calling this internally we want to be a little less wasteful. It's easy enough to just stash the result into the message on the first call, and then just return that on subsequent calls.
* | database: Add new notmuch_database_find_messageGravatar Carl Worth2009-10-21
|/ | | | | | | With this function, and the recently added support for notmuch_message_get_thread_ids, we now recode the find_thread_ids function to work just the way we expect a user of the public notmuch API to work. Not too bad really.
* Add notmuch_message_get_thread_ids functionGravatar Carl Worth2009-10-21
| | | | | | Along with all of the notmuch_thread_ids_t iterator functions. Using a consistent idiom seems better here rather than returning a comma-separated string and forcing the user to parse it.
* Move find_prefix function from database.cc to message.ccGravatar Carl Worth2009-10-21
| | | | | | It's definitely a better fit there for now, (and can likely eventually be made static as add_term moves from database to message as well).
* Add destroy functions for results, message, and tags.Gravatar Carl Worth2009-10-20
| | | | | | | | | | | | 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.
* Rename our talloc destructor functions to _destructor.Gravatar Carl Worth2009-10-20
| | | | | I want to reserve the _destroy names for some public functions I'm about to add.
* Implement 'notmuch dump'.Gravatar Carl Worth2009-10-20
This is a fairly big milestone for notmuch. It's our first command to do anything besides building the index, so it proves we can actually read valid results out from the index. It also puts in place almost all of the API and infrastructure we will need to allow searching of the database. Finally, with this change we are now using talloc inside of notmuch which is truly a delight to use. And now that I figured out how to use C++ objects with talloc allocation, (it requires grotty parts of C++ such as "placement new" and "explicit destructors"), we are valgrind-clean for "notmuch dump", (as in "no leaks are possible").