Re: [Dev-C++] itoa - simple implementation
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Per W. <pw...@ia...> - 2003-04-03 10:07:59
|
But the following code works: char buf1[30],buf2[30],*p1 = itoa(9,buf1), *p2 = itoa(10,buf2); It's quick since it doesn't use dynamic memory. It's reentrant since the thread uses it's own buffers and not a global buffer hidden somewhere within the itoa() implementation. It supports multiple stored answers for each thread. It may never leak memory, since the buffers are auto-allocated. That's why just about all itoa() implementations available with compilers or OS are taking the pointer as an input parameter. /Per W On Wed, 2 Apr 2003, Luigi Santillo wrote: > On Wed, Apr 02, 2003 at 01:48:06PM +0300, Ioannis Vranos wrote: > > This code is not good. Assume this: > > > > > > char *p=itoa(9), *q=itoa(10); > > > > > > I suggest to return a pointer on memory on the free store. > > > > Hello, > > You are right, my simple implementation does not cope well > with the above situation. I used the free store in my first > implementation, then, following some advice, I attempted to > use a static array, as that would probably be faster. > > Thanks for your suggestion > -- > >> gisan >> > > > ------------------------------------------------------- > This SF.net email is sponsored by: ValueWeb: > Dedicated Hosting for just $79/mo with 500 GB of bandwidth! > No other company gives more support or power for your dedicated server > http://click.atdmt.com/AFF/go/sdnxxaff00300020aff/direct/01/ > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > |