Memory Manager


Many API function require dynamic memory allocated in special way. These memory blocks are addressed by GSHandles. Basically a handle is a pointer to a pointer. There are some helper functions in the GSRoot package to manage theese memory spaces.

Examples:
    API_Coord   **hh = nullptr;

    hh = (API_Coord **) BMhAll (20 * sizeof (API_Coord));
    if (hh != nullptr && BMError () == NoError) {
        // safe dereferencing
        (*hh)[15].x = -32.56;
        (*hh)[15].y =  0.127;

        // this is also safe
        CalcArea (hh);               // pass the handle, not the master pointer!

        // dispose allocated memory
        BMhKill ((GSHandle *) &hh);
    }

Please use the BMxxx functions of the GSRoot package to operate on handles. Do not try to pass the address of a normal pointer allocated by malloc as a parameter, where ARCHICAD requires a handle. Also do not try to free a handle just calling the free function on the dereferenced value. Your add-on will crash in these cases.

These functions are disposing handles through the the structures given in their required parameters. They should be used instead of disposing handles by one by one as the definitions of the structures might change in later versions of the API.

ACAPI_DisposeAddParHdl
ACAPI_DisposeAttrDefsHdls
ACAPI_DisposeBeamRelationHdls
ACAPI_DisposeBeamSegmentRelationHdls
ACAPI_DisposeElemMemoHdls
ACAPI_DisposeRoomRelationHdls
ACAPI_DisposeWallRelationHdls