[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[cinvoke-dev] Pointer to pointer as ingoing parameters?
From: |
Michael Zedeler |
Subject: |
[cinvoke-dev] Pointer to pointer as ingoing parameters? |
Date: |
Fri, 07 Sep 2007 14:30:36 +0200 |
User-agent: |
Thunderbird 1.5.0.13 (X11/20070824) |
Hi C/Invoke users.
For various reasons I am trying to interface with Apache Portable
Runtime (apr) using C/Invoke from lua. It doesn't quite pan out the way
I was expecting to.
I have to call the function apr_allocator_create in apr which has been
defined as this:
apr_status_t
<http://www.schumann.cx/docs/apr/group__APR__Error__Codes.html#a0>
apr_allocator_create ( apr_allocator_t
<http://www.schumann.cx/docs/apr/group__APR__Pool__allocator.html#a0>
** /allocator/ )
apr_status_t is just an integer and I presume that apr_allocator_t is
supposed to be a pointer to a pointer that apr_allocator_create will
then modify for me in order to return the newly created allocator.
This is how I do it:
require("cinvoke_lua")
apr = clibrary.new("libapr-1.so.0")
strnatcasecmp = apr:get_function(Cint, "apr_strnatcasecmp", Cstring,
Cstring)
print("Casecmp(hello, car) = " .. strnatcasecmp("hello", "car"))
print("Casecmp(hello, hello) = " .. strnatcasecmp("hello", "hello"))
apr_allocator_create = apr:get_function( Cint, "apr_allocator_create",
Cptr )
allocator = {{}} -- my best take, but probably wrong
apr_allocator_create( allocator )
The script produces this output:
Casecmp(hello, car) = 1
Casecmp(hello, hello) = 0
Segmentation fault (core dumped)
When looking in the manual at Cptr, I can see that Cptr is not really
intended to be used as ingoing value, except when passing null values,
so thats problably where the problem is. Is there any way that I can
call functions using pointers to pointers like apr_allocator_create from
Lua using C/Invoke?
Regards,
Michael.
- [cinvoke-dev] Pointer to pointer as ingoing parameters?,
Michael Zedeler <=