Hi use this piece of code:
... if(dd->infowin_autosave) { char textbuf[16]; SNPrintf(textbuf, sizeof(textbuf), "%ld",dd->winX); saveDockyToolType(dd->GFXDock_ExePath, "WINX", textbuf); SNPrintf(textbuf, sizeof(textbuf), "%ld",dd->winY); saveDockyToolType(dd->GFXDock_ExePath, "WINY", textbuf); } ...
would be "better" to use ASPrintf instead?
... if(dd->infowin_autosave) { STRPTR textbuf; textbuf = ASPrintf("%ld",dd->winX); saveDockyToolType(dd->GFXDock_ExePath, "WINX", textbuf); textbuf = ASPrintf("%ld",dd->winY); saveDockyToolType(dd->GFXDock_ExePath, "WINY", textbuf); FreeVec(textbuf); } ...
Your usage of ASPrintf is bad because it leaks memory. Each call to ASPrintf allocates a new buffer and you have to free them all, not only the last one.
That's also the reason why I would recommend SNPrintf in your case. Allocating and freeing a new buffer each time is quite a bit of overhead which can be saved if you use SNPrintf and reuse one buffer.
The main question is how saveDockyToolType deals with the text buffer. I suppose it copies its contents so that you can indeed reuse the buffer after each call.
Ooops,. you're tight I missed one FreeVec(().
And thx that what I wanted to know if it's too overhead for so tiny strings/piece of code.
Yes IIRC saveDockyTooltType() makes acopy of data I'm passing.
Not sure, but maybe such function/code was done by you or anyone on this forum ;-):
THX
AOS4.1/SAM460ex/PPC460EX-1155MHZ/2048MB/RadeonHD6570/SSD120GB/DVDRW :-P