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

getMemory -- allocate memory using the garbage collector

Synopsis

Description

Allocate n bytes of memory using the GC garbage collector.

i1 : ptr = getMemory 8

o1 = 0xffff7c78d390

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 = 0xffff8b4919b0

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 = 0xffff8b4918d0

o3 : ForeignObject of type void*

Ways to use getMemory :

For the programmer

The object getMemory is a method function with options.