[FFmpeg-devel] [PATCH v14 2/5] compat/w32dlfcn.h: Remove MAX_PATH limit and replace LoadLibraryExA with LoadLibraryExW

nil-admirari at mailo.com nil-admirari at mailo.com
Mon Jun 13 20:03:20 EEST 2022


> Why do you use a 'do' loop? Can't you use the normal 2-step
> approach, i.e. call the winapi function with a NULL buffer,
> and then use the returned size to allocate the buffer.
> This way you always need a single allocation only.

GetModuleFileNameW does not follow this convention:
https://docs.microsoft.com/en-us/windows/win32/api/libloaderapi/nf-libloaderapi-getmodulefilenamew

> If the length of the path exceeds the size that the nSize parameter specifies,
> the function succeeds and the string is truncated to nSize characters
> including the terminating null character.

MS does the looping too in their WIL library:
https://github.com/microsoft/wil/blob/master/include/wil/win32_helpers.h#L339-L341.





More information about the ffmpeg-devel mailing list