: thus on Tue, 23 Dec 1997 00:31:11 -0600, Akuma/Chris virtually wrote: Chris>> any clues on this one? obviously i'm not changing boot_time Chris>> anywhere, but the string is different everytime i print it out. Chris>> WTF? this is currently running fine on my mud. it prints out the Chris>> correct time and everything, but why not here? the code hasn't been Chris>> changed in any way, except for the log()'s (and the ctime() thing) Chris> ok, i think i may have solved my own problem. from what i tried Chris> out, it seems that ctime/asctime(localtime()) uses a static buffer Chris> to write out the string, and then returns the pointer to that Chris> string. That's always been the case with ctime, asctime. On solaris you can supply ctime_r with a buf of at least 26 length to write to. Subsequent calls to ctime/asctime should overwrite the previous information. Calling it twice in the same printf can lead unwanted results. ctime() writes to a static string buffer, the length of which should be 26 characters. Chris> so it would cause this small problem. I don't know if it's only on Chris> my mud or not, but this seems to be the case. the solution i used, Chris> was to just str_dup() it, and then FREE() it at the end of the Chris> function. which is no big deal, unless someone can find a problem Chris> with it. anyway, just to answer my own question: str_dup() the Chris> pointer, then FREE/free it later. If you need a snapshot instance of that time to remain constant, then yes, you will have to dup the string before another call to ctime/asctime. +------------------------------------------------------------+ | Ensure that you have read the CircleMUD Mailing List FAQ: | | http://democracy.queensu.ca/~fletcher/Circle/list-faq.html | +------------------------------------------------------------+
This archive was generated by hypermail 2b30 : 12/08/00 PST