Paste: prefixed array

Author: kssreeram
Mode: text
Date: Mon, 10 Jan 2011 12:02:56
Plain Text |
record PrefixedArray[P, T] (
    prefix:P,
    data:Array[T,0],
);

[P, T]
allocatePrefixedArray(static P, static T, arrayElementsCount) {
    var ptr = libc.malloc(TypeSize(PrefixedArray[P,T]) + TypeSize(T)*arrayElementsCount);
    return Pointer[PrefixedArray[P,T]](ptr);
}

[P, T]
freePrefixedArray(ptr: Pointer[PrefixedArray[P, T]]) {
    libc.free(RawPointer(ptr));
}

New Annotation

Summary:
Author:
Mode:
Body: