# hb_gcAlloc()

Allocates memory that will be collected by the garbage collector.

Syntax

  #include <hbapi.h>
  void *hb_gcAlloc( ULONG ulSize,
  HB_GARBAGE_FUNC_PTR pCleanupFunc );

Arguments

  <ulSize> Requested size of memory block
  <pCleanupFunc> Pointer to HB_GARBAGE_FUNC function that will be called directly before releasing the garbage memory block or NULL. This function should release all other memory allocated and stored inside the memory block. For example, it releases all items stored inside the array. The functions receives a single parameter: the pointer to memory allocated by hb_gcAlloc().

Returns

  The pointer to allocated memory or it generates an internal unrecoverable error.

Description

  hb_gcAlloc() is used to allocate the memory that will be tracked by the garbage collector. It allows to properly release memory in case of self-referencing or cross-referencing harbour level variables. Memory allocated with this function should be released with hb_gcFree() function or it will be automatically deallocated by the GC if it is not locked or if it is not referenced by some harbour level variable.

Examples

          See source/vm/arrays.c

Status

  Clipper

Compliance

  This function is a Harbour extension

Platforms

  All

Files

  source/vm/garbage.c

See Also

- hb_gcFree()