Strdupa() Implementation For Visual C
I am trying to port a C (not C++) program from GCC to Visual Studio.
The GCC specific function strdupa() is widely used in this program. Is there any way to implement this function for Visual C.
PS. I understand that it uses alloca() and it is unsafe. But it works very well on GCC now and I think it is safer to implement the same function in one place then change the logic of program. I also don't want performance to decrease.
I'd implement it as a macro:
#define strdupa(a) strcpy((char*)alloca(strlen(a) + 1), a)
That way it is not in a function and so the alloca'd string won't be freed prematurely.
- → OctoberCMS Backend Loging Hash Error
- → "failed to open stream" error when executing "migrate:make"
- → OctoberCMS - How to make collapsible list default to active only on non-mobile
- → Create plugin that makes objects from model in back-end
- → October CMS Plugin Routes.php not registering
- → OctoberCMS Migrate Table
- → How to install console for plugin development in October CMS
- → OctoberCMS Rain User plugin not working or redirecting
- → October CMS Custom Mail Layout
- → October CMS - How to correctly route
- → October CMS create a multi select Form field
- → How to update data attribute on Ajax complete
- → October CMS - Conditionally Load a Different Page