[cffi-devel] CFFI-USER: Dereferencing an address to a pointer array ... ?
Frank Goenninger
frgo at mac.com
Sat Nov 17 19:30:43 UTC 2007
Hi all:
I have in C in a library:
typedef struct __tsPMDevInfo
{
... some slots in here; don't matter ...
} tsPMDevInfo, *ptsPMDevInfoPtr;
//
------------------------------------------------------------------------
// nFindPMs -- Find PM Devices on all available serials
//
------------------------------------------------------------------------
-
int nFindPMs( ptsPMDevInfoPtr **pppsPMDevInfoArray,
int *pnNrPMsFound )
{
int nRC = 0;
ptsPMDevInfoPtr *ppsPMDevInfoArray = NULL;
.... Here, memory gets allocated and
ppsPMDevInfoArray points to an array of
pointers to struct tsPMDevInfo !
if( pppsPMDevInfoArray != NULL )
*pppsPMDevInfoArray = ppsPMDevInfoArray;
if( pnNrPMsFound != NULL )
*pnNrPMsFound = nNrPMs;
if( nNrPMs > 0 )
nRC = PMIO_RC_OK;
else
nRC = PMIO_RC_NO_PM_FOUND;
return nRC;
}
In Lisp-land I do (simplified):
(defcfun ("nFindPMs" %nFindPMs) pmio-rc
(ppsPMDevInfoPtr :pointer)
(pnNrPMs :pointer))
(defun find-pms (ppsPMDevInfoPtr pnNrPMs)
(%nFindPMs ppsPMDevInfoPtr pnNrPMs))
I do get a valid value for the nr of PMs back with
(mem-ref pnNrPMs :int 0)
But I am unable to get a valid foreign pointer back for
ppsPMDevInfoPtr :
(mem-ref ppsPMDebInfoPtr :pointer 0)
always returns an invalid value (no valid memory address). So, the
question is: How do I return a pointer to an array of pointers ?
In C land everything is OK and the pointer array is valid: check via
ppsPMDebInfoPtr[0] -> This is the pointer to a valid struct tsPMDevInfo.
Thx for any pointers ;-) !!!
Frank
-------------- next part --------------
A non-text attachment was scrubbed...
Name: PGP.sig
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://mailman.common-lisp.net/pipermail/cffi-devel/attachments/20071117/1ecb8236/attachment.sig>
More information about the cffi-devel
mailing list