Table of Contents

Resource Management

These routines are supplied as a means to collect multiple memory handlers, for release with a single statment.


Such as wxTreeCtrl, which uses Memory to store the Unique ID's for items contained within it.

  • proc add_resource(integer resource_stack, object memory_handle)   
  • proc free_resource(integer resource_stack)   
  • proc new_resource()   
  • proc release_resources(integer resource_stack)   
  • const wxBaseResource   


    Table of Contents

    [proc]
    add_resource
    (integer resource_stack, object memory_handle)

    Category: Resource Management

    resource_stack is the stack in which you want to store the memory handle on. If you do not create one through the new_resource() function, you can use the wxBaseResource as a general stack. If resource_stack is not valid, it does not track the memory handle at all. memory_handle can be either a single atom value of a Memory Pointer, or a sequence of Memory Pointers to be added to the list, for quick release. See also release_resources()

    See Also: free_resource, new_resource, release_resources, wxBaseResource



    Table of Contents

    [proc]
    free_resource
    (integer resource_stack)

    Category: Resource Management

    This will remove an entire set from the Resource Management stack. If any handles are in in it, when you call this procedure, it will automatically free them, before removing it from usage. Once a resource has been used in this routine, it becomes invalid. If resource_stack is '0', all resource stacks are removed, freeing up any memory handles in them.

    See Also: add_resource, new_resource, release_resources, wxBaseResource



    Table of Contents

    [proc]
    new_resource
    ()

    Category: Resource Management

    This creates a new Resource Stack, that allows you to store memory handles into. This is useful if you don't want to release all resources at one time.

    See Also: add_resource, free_resource, release_resources, wxBaseResource



    Table of Contents

    [proc]
    release_resources
    (integer resource_stack)

    Category: Resource Management

    This releases the accumilated list of pointers of a stack, in one single statement. Once all memory handles are released, the resource_stack list is cleared, and all handles that was released become invalid. If resource_stack is an invalid stack, nothing is done, and control is returned immediately to the caller.

    example:

     sequence holders
     for x = 1 to 4 do
        -- Create the Actual wxTreeCtrl Items
        holders &={ add_tree_item(MyTree,MainParent,sprintf("Item %d",x),-1,-1), {} }
        for y = 1 to 3 do
           -- Add some Sub-Items
           holders[x][2] &= add_tree_item(MyTree,holders[x][1],sprintf("Sub-Item %d",x),-1,-1)
        end for
        -- Add the pointers to be free'd when we're done.
        add_resources(wxBaseResource,holders[x][1] & holders[x][2])
        -- Get the actual Unique ID's for said holders
        holders[x][1] = peek4u(holders[x][1])
        for y = 1 to 3 do
           holders[x][2][y] = peek4u(holders[x][2][y])
        end for
     end for
     -- Release all the accumulated memory handlers, since we now have actual unique id's for all the wxTreeCtrl items
     release_resources(wxBaseResource)
    

    See Also: add_resource, free_resource, new_resource, wxBaseResource



    Table of Contents

    [const]
    wxBaseResource

    Category: Resource Management

    This is the base stack, that you can use by default, without having to allocate a new resource stack. It is provided as the default stack, and cannot be removed through free_resource()

    See Also: add_resource, free_resource, new_resource, release_resources