Macaulay2 » Documentation
Packages » ForeignFunctions :: getMemory
next | previous | forward | backward | up | index | toc

getMemory -- allocate memory using the garbage collector



Allocate n bytes of memory using the GC garbage collector.

i1 : ptr = getMemory 8

o1 = 0x79ed231cc360

o1 : ForeignObject of type void*

If the memory will not contain any pointers, then set the Atomic option to true.

i2 : ptr = getMemory(8, Atomic => true)

o2 = 0x79ed23099b30

o2 : ForeignObject of type void*

Alternatively, a foreign object type T may be specified. In this case, the number of bytes and whether the Atomic option should be set will be determined automatically.

i3 : ptr = getMemory int

o3 = 0x79ed23099a50

o3 : ForeignObject of type void*

Ways to use getMemory :

For the programmer

The object getMemory is a method function with options.