[Haskell] Finding pointer size

Stefan O'Rear stefanor at cox.net
Fri Feb 16 01:04:40 EST 2007


On Thu, Feb 15, 2007 at 11:56:58PM -0600, Rob Hoelz wrote:
> I'm working with the Foreign module, and I need to allocate a pointer
> to a pointer (in C, a char **).  The problem is, I don't know how to
> find out the size of a char * in Haskell.  Here's the basic layout of
> the code:
> 
> allocaBytes len $ \ array -> ... -- len is the size of the char ** to
> be allocated times sizeof(char *).

import Foreign.Marshal.Array

allocaArray nr_of_pointers $ \arrar -> ...


automatically figures the sizeof(char *)

if you really want to know ... sizeOf (undefined ;: Ptr CChar)

Stefan


More information about the Haskell mailing list