free: Explicitly release natively allocated memory

freeR Documentation

Explicitly release natively allocated memory

Description

This function can be called to explicitly release/garbage collect memory associated with a native object. This can also be done via a finalizer on the external pointer. This function does not have any mechanism to validate its input was dynamically allocated and has not already been released. It is up to the caller to call this appropriately.

Usage

free(x)

Arguments

x

an external pointer or RCReference identifying the address of the memory to be released.

Value

NULL. This function is used for its side-effect of releasing the memory associated with the object.

Author(s)

Duncan Temple Lang

References

The free C routine built-in for all platforms.

See Also

alloc addFinalizer

Examples


 ptr = alloc(100, FALSE)
 free(ptr)

 ###############


 type = structType(list(s = sint16Type,
                        i = sint32Type,
                        d = doubleType,
                        string = stringType))

  cif = CIF(pointerType)
    # getStructP allocates the MyStruct and returns a pointer to it.
  ans = callCIF(cif, "getStructP")
  getStructValue(ans, type)

#  free(ans)

omegahat/Rffi documentation built on Nov. 29, 2023, 12:48 a.m.