Hi,

I've got a conceptional question according to strings.

I just want to get some other ideas to check mine :-)

I wrote some functions for logfile writing:

Code:
void ediag(STRING* fctName, STRING* loglevel, STRING* diagStr);

void ediag_entering(STRING* fctName);

void ediag_exiting(STRING* fctName);



As you can see there's one general function to write strings into the log with additional parameters for the function name (fctName) and a log level.

Then I have 2 functions ediag_entering and ediag_exiting that should be used at the beginning and end of the functions, e.g.

Code:
void myTestFct() {
STRING* fctName = str_create("void myTestFct()");
ediag_entering(fctName);

// do some stuff here

ediag(fctName, LEVEL_DEBUG, _str("my debug message"));

// do some stuff here

ediag_exiting(fctName);
}



So far so good ... my my the problem:

STRING* fctName = str_create("void myTestFct()");

this created string has to be removed from memory at the end of the function.

I could simply do this in the ediag_exiting function, but there are also actions that depend on an entity's lifetime and don't have a proper end (they never reach ediag_exiting).

So what's the best (or good) way to handle this str_create???

B.t.w.:
I'd like to avoid something like this:
ediag_entering(_str("void myTestFct()"));
...
ediag_exiting(_str("void myTestFct()"));

Any suggestions?

Regards,
Pegamode.