AndrewBelt / osdialog

A cross platform wrapper for OS dialogs like file save, open, message boxes, inputs, color picking, etc.
Creative Commons Zero v1.0 Universal
122 stars 19 forks source link

Changing Signature of osdialog_file to avoid free and strdup #3

Closed RicoP closed 5 years ago

RicoP commented 5 years ago

I would like to use osdialog_file in my game engine but I would like to be able to use my custom allocator.

osdialog_file uses both free and strdup which makes my life a bit harder. Would it be possible to change the signature of osdialog_file to be

bool osdialog_file(char * destination, int destinationMaxLength, osdialog_file_action action, const char *path, const char *filename, osdialog_filters *filters);

So we can use our own buffer, without worriing about freeing the buffer space.

AndrewBelt commented 5 years ago

If I break the API, I'll do something like this, but right now osdialog follows https://github.com/VCVRack/Rack, which is waiting on a v1 release. I'll probably forget about this task by tomorrow though.

r-lyeh commented 5 years ago

You can also try something quick and use following macros:

#ifndef OSDIALOG_MALLOC
#define OSDIALOG_MALLOC malloc
#endif

#ifndef OSDIALOG_FREE
#define OSDIALOG_FREE free
#endif

#ifndef OSDIALOG_STRDUP
#define OSDIALOG_STRDUP strdup
#endif
AndrewBelt commented 5 years ago

That's reasonable enough. 7bb7dd7688868aef593de2bcd468bed92c71ab00