#include <util.h>
Classes | |
| class | clonea_data |
Public Member Functions | |
| clonea (const text *ref) | |
| clonea (const clonea &ref) | |
| const clonea & | operator= (const clonea &ref) |
| operator const char * () const | |
| operator size_t () const | |
Public Attributes | |
| clonea_data * | data |
This memory will be freed up when the clonea object itself is deleted. The clonea object itself is quite small, so its not a significant overhead to be creating temporary objects on the stack. The memory they hold though, is only created once, and referred to with a reference count. This may seem like a lot of coding and a lot of effort, to just get a temporary string, but it is a work-around for the fact that so many C functions exist which take a c_str (const char*) pointer as an argument... but this is diabloically horrible when it comes to avoiding race conditions.
There is a convenience defined macro for getting a temporary string from a text object, which uses the clonea object:
TEMP_STRING(str) ... where str is the text object. e.g.
text path; ... ifstream is(TEMP_STRING(path), ios::binary);
1.5.8