Re: [MLton-user] Feature request: MLton.Pointer

Top Page
Attachments:
Message as email
+ (text/plain)
Delete this message
Reply to this message
Author: Matthew Fluet
Date:  
To: John Reppy
CC: mlton-user
Subject: Re: [MLton-user] Feature request: MLton.Pointer
On Mon, 2 Jun 2008, John Reppy wrote:
> The MLton.Pointer structure should have
>
>     val sizeofPtr : word

>
> so that one can allocate arrays of pointers in the C heap.


Sounds reasonable.

BTW, for importing "malloc", you should use
_import "malloc": C_Size.word -> MLton.Pointer.t;
rather than
_import "malloc": Word32.word -> MLton.Pointer.t;
to pass the appropriately sized 'size_t' object on 32-bit and 64-bit
platforms.

The "structure C_Size : WORD" is available from
"$(SML_LIB)/basis/c-types.mlb".

You could also use C_Size.wordSize to compute the sizeof a pointer (MLton
asserts that sizeof(void*) == sizeof(size_t) and CHAR_BIT == 8).

_______________________________________________
MLton-user mailing list

http://mlton.org/mailman/listinfo/mlton-user