Re: [AD] SF.net SVN: alleg:[11691] allegro/branches/4.9/addons/native_dialog |
[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
- To: "Coordination of admins/developers of the game programming library Allegro" <alleg-developers@xxxxxxxxxx>
- Subject: Re: [AD] SF.net SVN: alleg:[11691] allegro/branches/4.9/addons/native_dialog
- From: Peter Wang <novalazy@xxxxxxxxxx>
- Date: Tue, 24 Feb 2009 17:35:22 +1100
2009/2/24 <eglebbk@xxxxxxxxxx>:
> Revision: 11691
> http://alleg.svn.sourceforge.net/alleg/?rev=11691&view=rev
> Author: eglebbk
> Date: 2009-02-24 04:29:25 +0000 (Tue, 24 Feb 2009)
>
> Log Message:
> -----------
> Added OS X native file selector.
> Changed the type of the index argument of al_get_native_file_dialog_path
> from int to size_t, to silence a warning on OS X.
> Tested, but I'm having problems running the example that goes with this.
> +/* al_get_native_file_dialog_path
> + */
> +ALLEGRO_PATH *al_get_native_file_dialog_path(
> + ALLEGRO_NATIVE_FILE_DIALOG *fd, size_t i)
> +{
> + if (i < [fd->files count]) {
> + /* NOTE: at first glance, it looks as if this code might leak
> + * memory, but in fact it doesn't: the string returned by
> + * UTF8String is freed automatically when it goed out of scope
> + * (according to the UTF8String docs anyway).
> + */
> + const char *s = [[fd->files objectAtIndex:i] UTF8String];
> + return al_path_create(strdup(s));
> + }
This looks like two memory leaks:
- al_path_create() copies its argument so strdup() creates a leak.
- The caller of al_get_native_file_dialog_path() isn't expected to
call al_path_free() on the return value.
Peter