Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Bug Reports / [DGDK] char pointer functions

Author
Message
Mireben
15
Years of Service
User Offline
Joined: 5th Aug 2008
Location:
Posted: 27th Feb 2010 16:14
This is rather a change request than a bug report. Dark GDK functions that return char pointers create new strings every time they are called and to avoid a memory leak, the returned string must be deleted after use. This comes up again and again on the forum because people don't know it and it is not in the documentation. It would be best to change the functions so that they expect a char buffer from the calling function. For example, instead of this:


the function would be declared like this:


and it would be called like this:


The function could then return an error code if the resulting string was longer than the supplied buffer.

If this change will not be done (I understand it's much work), then please include a warning into the Dark GDK documentation for all such functions, so that new users will know how to use them correctly, without creating memory leaks. When I first learned about this, it surprised me that such an important information is not in the help.
IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 28th Feb 2010 00:54
I think I can state that it's very unlikely that the core library will change to follow your suggestions - you are forgetting that the same code is used for both DBPro and GDK and this just would not work for DBPro.

It may be that there's a way to handle this outside of the GDK though by using some very thin wrappers. If that turns out to be possible, then I'll write them and release them to the community myself.

Mireben
15
Years of Service
User Offline
Joined: 5th Aug 2008
Location:
Posted: 28th Feb 2010 10:49 Edited at: 28th Feb 2010 10:55
I thought that it's too much to ask, but as I mentioned, I'd be happy with a warning in the documentation as well.

Thank you very much for the quick answer to this and to my other reports. It's good to see that they are taken care of.

P.S. Sorry for those reports which are not bugs after all, but I'm glad to have learned the explanation given.

Login to post a reply

Server time is: 2024-04-26 22:06:20
Your offset time is: 2024-04-26 22:06:20