Fix <direct-struct-array>

db4
Slava Pestov 2008-12-18 21:17:24 -06:00
parent 7836b2c6f4
commit 74df92d12d
2 changed files with 13 additions and 3 deletions

View File

@ -1,6 +1,7 @@
IN: struct-arrays.tests
USING: struct-arrays tools.test kernel math sequences
alien.syntax alien.c-types destructors libc accessors ;
alien.syntax alien.c-types destructors libc accessors
destructors ;
C-STRUCT: test-struct
{ "int" "x" }
@ -27,3 +28,12 @@ C-STRUCT: test-struct
0 [ [ test-struct-x ] [ test-struct-y ] bi / + ] reduce
] with-destructors
] unit-test
[ ] [ ALIEN: 123 10 "test-struct" <direct-struct-array> drop ] unit-test
[ ] [
[
10 "test-struct" malloc-struct-array
underlying>> &free drop
] with-destructors
] unit-test

View File

@ -32,9 +32,9 @@ ERROR: bad-byte-array-length byte-array ;
] keep struct-array boa ; inline
: <direct-struct-array> ( alien length c-type -- struct-array )
struct-array boa ; inline
heap-size struct-array boa ; inline
: malloc-struct-array ( length c-type -- struct-array )
heap-size [ calloc ] 2keep <direct-struct-array> ;
[ heap-size calloc ] 2keep <direct-struct-array> ;
INSTANCE: struct-array sequence