sscanf simulation in symbian

Login to reply to this topic.
Thu, 2007-03-08 11:10
Joined: 2006-12-18
Forum posts: 42
Hello all,
when i use library function sscanf application crashes due to leak. I don't want to invoke CloseSTDLIB function call.

Can you plz. tell me the simulation of sscanf in symbian. As we know we can simulate sprintf throug FormatList .


Thu, 2007-03-08 11:22
Joined: 2004-11-29
Forum posts: 1246
Re: sscanf simulation in symbian
I don't think there is any sscanf equivalent in symbian. Nothing as close as sprintf and Format at least.

Probably because sscanf is a pretty funky function to begin with Smiley

Maybe you can use TLex8 for your needs.

Why do you not want to invoke CloseSTDLIB?
Thu, 2007-03-08 11:32
Joined: 2006-12-18
Forum posts: 42
Re: sscanf simulation in symbian
Actually i m working in a project where many times this function has been invoked
If i invoke CloseSTDLIB() function at the time of application exit it can free memory that time . But i need to free memory as my program flows .


Can anybody tell me the prototype of sscanf using TLex or other way round ??
Thu, 2007-03-08 12:26
Joined: 2004-11-29
Forum posts: 1246
Re: sscanf simulation in symbian
It doesn't matter how many times you use the same function, it will not allocate more memory then if you call it once I would say.

The reason it does allocate memory is because the standard implementations of many stdlib functions like printf and scanf is using a static local buffer for temporary string storage.

But since writable static data isn't supported in symbian dlls, the symbian implementation will use TLS (Thread local storage, one pointer of writable static data per loaded dll is allowed), and allocate the buffer here.

For performance reasons you don't want to reallocate this buffer each time the functions is called, so it is only done on the first call, and then it will be reused in the following calls.

This can be easily checked through User::Heap().AllocSize(), if you don't think it sounds reasonable. (I havn't actually double checked it myself, but would be surprised if it worked otherwise)
Thu, 2007-03-08 13:19
Joined: 2006-12-18
Forum posts: 42
Re: sscanf simulation in symbian
ohh if this is the case , my problem is solved.

Thanku very much.
  • Login to reply to this topic.