[vlc-devel] [PATCH 22/41] Implement OS/2 specific initialization

KO Myung-Hun komh78 at gmail.com
Fri Oct 14 16:31:33 CEST 2011



Rémi Denis-Courmont wrote:
> On Tue, 11 Oct 2011 20:18:08 +0900, KO Myung-Hun <komh78 at gmail.com> wrote:
>>>> +void system_Init( void )
>>>> +{
>>>> +    PPIB ppib;
>>>> +    CHAR psz_path[ CCHMAXPATH ];
>>>> +    PSZ  psz_dirsep;
>>>> +
>>>> +    DosGetInfoBlocks( NULL, &ppib );
>>>> +
>>>> +    DosQueryModuleName( ppib->pib_hmte, sizeof( psz_path ), psz_path
> );
>>>> +
>>>> +    /* remove the executable name */
>>>> +    psz_dirsep = strrchr( psz_path, '\\');
>>>> +    if( psz_dirsep )
>>>> +        *psz_dirsep = '\0';
>>>> +
>>>> +    /* remove the last directory, i.e, \\bin */
>>>> +    psz_dirsep = strrchr( psz_path, '\\' );
>>>> +    if( psz_dirsep )
>>>> +        *psz_dirsep = '\0';
>>>> +
>>>> +    asprintf( &psz_vlcpath, "%s\\lib\\vlc", psz_path );
>>>
>>> This works for VLC. I don't mind but this may be a problem with LibVLC,
>>> as
>>> system_Init() may be entered multiple tines.
>>>
>>
>> I don't understand why this may be a problem when being entered multiple
>> times.
> 
> If system_Init() is called multiple times, asprintf() will overwrite the
> psz_vlcpath value. This will result in a memory leak of the previous value.
> Also there is a race condition.
> 

Is this true for Win32 ?

Anyway, fixed.

> Maybe in VLC 1.3 will be enhanced so that system_Init() is not re-entrant
> but it is not done yet.
> 
>> And LibVLC call system_Init() many times without system_End() ?
> 
> It can happen if the application creates multiple instances with
> libvlc_new().
> 
> Maybe you don't care about this on OS/2.
> 

No. I don't.

-- 
KO Myung-Hun

Using Mozilla SeaMonkey 2.0.14
Under OS/2 Warp 4 for Korean with FixPak #15
On AMD ThunderBird 1GHz with 512 MB RAM

Korean OS/2 User Community : http://www.ecomstation.co.kr

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: 0012-Implement-OS-2-specific-initialization.patch
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20111014/bc1ccb45/attachment.ksh>


More information about the vlc-devel mailing list