hb_gcAlloc()

hb_gcAlloc()

Allocates memory that will be collected by the garbage collector.

Syntax

      #include "hbapi.h"
      void * hb_gcAlloc( HB_SIZE nSize,
      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 src/vm/arrays.c

Compliance

Harbour

Platforms

All

Files

src/vm/garbage.c

Seealso

hb_gcFree()

Advertisements

3 responses to “hb_gcAlloc()

  1. Pingback: Harbour All Functions – H | Viva Clipper !

  2. Pingback: Harbour Garbage Collection Functions | Viva Clipper !

  3. Pingback: Harbour RG Summary | Viva Clipper !

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s