Le 06/11/2013 00:58, Bruce a écrit :
> Dear experts,
>
> Can anyone see what I'm doing wrong here.  Source archive is attached,
> but here is the entire code:
>
> ----------------------------------------------------------------------
> ' Gambas module file
>
> ' void uuid_generate(uuid_t out);
> Extern UUID_Gen(op As Pointer) As Pointer In "libuuid:1" Exec
> "uuid_generate"
>
> ' void uuid_unparse(uuid_t uu, char *out)
> Extern UUID_ToStr(ip As Pointer, op As Pointer) As Pointer In
> "libuuid:1" Exec "uuid_unparse"
>
> Public Sub Main()
>
>    Dim OP As Pointer    ' ptr to the uuid returned by uuid_generate
>    Dim SP As Pointer    ' ptr to the string returned by uuid_unparse
>
>    Dim sOP As String    ' our result (UUID as a string)
>    Dim rtn As Integer   ' int rtn code from extern funcs
>    Dim sArch As String  ' system architecture (selects pointer length)
>
>    sArch = System.Architecture
>    Error "Arch=" & sArch
>
>    OP = Alloc(IIf(sArch = "x86", 4, 8))
>    SP = Alloc(IIf(sArch = "x86", 4, 8))
>
>    rtn = UUID_Gen(OP)
>    Error "UUID_Gen=" & rtn
>
>    rtn = UUID_ToStr(OP, SP)
>    sOP = String@(SP)
>    Error Subst("UUID_ToStr=&1\tUUID=&2", rtn, sOP)
>    Error
>
>    Free(OP)
>    Free(SP)
>
> End         '<- the problem happens here
> ----------------------------------------------------------------------
>
> I get variously a SegFault(11) or an Aborted(6) here. The Segfault shows
> nothing, but the Abort produces an invalid pointer dump like the
> following:
>

What is the exact definition of 'uuid_t' ?

Also, you can use valgrind to know when exactly the faulty memory access 
occurs. This will give better clues.

Regards,


-- 
Benoît Minisini

------------------------------------------------------------------------------
November Webinars for C, C++, Fortran Developers
Accelerate application performance with scalable programming models. Explore
techniques for threading, error checking, porting, and tuning. Get the most 
from the latest Intel processors and coprocessors. See abstracts and register
http://pubads.g.doubleclick.net/gampad/clk?id=60136231&iu=/4140/ostg.clktrk
_______________________________________________
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user

Reply via email to