vsnprintf()
Posted: Fri Mar 28, 2025 9:30 am
I try to use libvlc.pbi and vlc.pbi in Linux.
https://www.purebasic.fr/english/viewtopic.php?t=77848
For that I added in vlc.pbi
This works in general. The application is starting, but results in memory errror.
Same like here:
https://www.purebasic.fr/english/viewtopic.php?p=392883
It is used in a vlc logging callback (vlc_eventdebug which calls vlc_stringformat)
The problem is the va_list args.
In Windows it works.
In linux it looks that the args pointer points to a wrong address.
Any idea?
https://www.purebasic.fr/english/viewtopic.php?t=77848
For that I added in vlc.pbi
Code: Select all
CompilerSelect #PB_Compiler_OS
CompilerCase #PB_OS_Windows
CompilerIf #PB_Compiler_Processor = #PB_Processor_x86
Macro snprintf_name : "__vsnprintf" : EndMacro
CompilerElse
Macro snprintf_name : "_vsnprintf" : EndMacro
CompilerEndIf
CompilerCase #PB_OS_Linux
Macro snprintf_name : "vsnprintf" : EndMacro
CompilerCase #PB_OS_MacOS
CompilerEndSelect
ImportC ""
snprintf(*str.p-utf8, size.l, *format.p-utf8, ap.i) As snprintf_name
EndImport
Same like here:
https://www.purebasic.fr/english/viewtopic.php?p=392883
It is used in a vlc logging callback (vlc_eventdebug which calls vlc_stringformat)
Code: Select all
Procedure.s vlc_stringformat(*fmt, args)
Protected sret.s
Protected c.i
c = snprintf(#Null, 0, *fmt, args)
If c
Protected *pm = AllocateMemory(c)
If *pm
snprintf(*pm, c, *fmt, args)
sret = vlc_safePeekS(*pm, c)
FreeMemory(*pm)
EndIf
EndIf
ProcedureReturn sret
EndProcedure
ProcedureC vlc_eventdebug (*vlc.vlc, level.i, *ctx, *fmt, args)
Select level
Case #LIBVLC_DEBUG
Debug "#LIBVLC_DEBUG : " + vlc_stringformat(*fmt, args)
Case #LIBVLC_NOTICE
Debug "#LIBVLC_NOTICE : " + vlc_stringformat(*fmt, args)
Case #LIBVLC_WARNING
Debug "#LIBVLC_WARNING : " + vlc_stringformat(*fmt, args)
Case #LIBVLC_ERROR
Debug "#LIBVLC_ERROR : " + vlc_stringformat(*fmt, args)
EndSelect
EndProcedure
In Windows it works.
In linux it looks that the args pointer points to a wrong address.
Any idea?