notmuch clon
Find a file
Carl Worth 2ce552b5f7 Fix lifetime-maintenance bug with std::string and c_str()
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.
2009-10-21 23:20:18 -07:00
.gitignore .gitignore: Ignore generated file Makefile.dep 2009-10-20 23:13:28 -07:00
database-private.h notmuch dump: Fix the sorting of results. 2009-10-21 00:35:56 -07:00
database.cc Rename NOTMUCH_MAX_TERM to NOTMUCH_TERM_MAX 2009-10-21 14:10:00 -07:00
date.c Hook up our fancy new notmuch_parse_date function. 2009-10-19 13:35:29 -07:00
Makefile Implement 'notmuch dump'. 2009-10-20 21:21:39 -07:00
message-file.c Rename private notmuch_message_t to notmuch_message_file_t 2009-10-20 15:09:51 -07:00
message.cc Fix lifetime-maintenance bug with std::string and c_str() 2009-10-21 23:20:18 -07:00
message.h notmuch: Switch from gmime to custom, ad-hoc parsing of headers. 2009-10-19 13:00:43 -07:00
notmuch-private.h Rename NOTMUCH_MAX_TERM to NOTMUCH_TERM_MAX 2009-10-21 14:10:00 -07:00
notmuch.c notmuch dump: Fix to print spaces between tags. 2009-10-21 14:02:51 -07:00
notmuch.h Add notmuch_message_get_thread_ids function 2009-10-21 15:23:08 -07:00
query.cc notmuch dump: Fix the sorting of results. 2009-10-21 00:35:56 -07:00
xutil.c Add wrappers for regcomp and regexec to xutil.c. 2009-10-21 15:07:20 -07:00
xutil.h Add wrappers for regcomp and regexec to xutil.c. 2009-10-21 15:07:20 -07:00