Last active
November 2, 2022 16:26
-
-
Save BetterProgramming/2703ee6c4d659dc7e6a9be9a225aa3d9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.graalvm.nativeimage.c.struct.SizeOf; | |
import static org.graalvm.nativeimage.UnmanagedMemory.calloc; | |
import static org.graalvm.nativeimage.UnmanagedMemory.malloc; | |
public static CSpeechBusinessData allocData() { | |
// malloc() initializes only. allocated space is dirty. | |
CSpeechBusinessData csbd = malloc( | |
SizeOf.get(CSpeechBusinessData.class) | |
); | |
return csbd; | |
} | |
// allocate an array of * | |
public static WordPointer allocArray(int size) { | |
// calloc() initializes and sanitizes | |
return calloc(size * SizeOf.get(WordPointer.class)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment