class Allocator

Class do easily allocate/deallocate memory in Torch.

Public Methods

[more] Allocator()
Create a new allocator
[more]void* alloc(size_t size, int object_style=0)
Returns size bytes of allocated memory.
[more]void* realloc(void* ptr, size_t size)
Reallocate a part of the memory which has been already allocated with alloc (and object_style=0).
[more]void free(void* ptr)
Force given pointer to memory to be freed now.
[more]void retain(void* ptr, int object_style=0)
Tells to the allocator that it should handle the memory given by ptr.
[more]int release(void* ptr)
Tells to the allocator to stop taking in account the memory given by ptr.
[more]void steal(void* ptr, Allocator* allocator)
Handles the memory given by ptr which was previouly handled by allocator.
[more]void steal(Allocator* allocator)
Steals all pointers contained in allocator
[more]AllocatorNode* isMine(void* ptr)
Returns true iff ptr is handled by the allocator
[more]void freeAll()
Force all pointers contained in the allocator to be freed now.
[more]static void* sysAlloc(int size)
System allocation.
[more]static void* sysRealloc(void* ptr, int size)
System reallocation.


Documentation

Class do easily allocate/deallocate memory in Torch. The memory allocated by an allocator will be destroyed when the allocator will be destroyed.

o Allocator()
Create a new allocator

ovoid* alloc(size_t size, int object_style=0)
Returns size bytes of allocated memory.

ovoid* realloc(void* ptr, size_t size)
Reallocate a part of the memory which has been already allocated with alloc (and object_style=0). Same behaviour as the realloc() system function.

ovoid free(void* ptr)
Force given pointer to memory to be freed now. It considers the object_style given by alloc() and calls the Object destructor, if needed.

ovoid retain(void* ptr, int object_style=0)
Tells to the allocator that it should handle the memory given by ptr. Take in account the object_style.

oint release(void* ptr)
Tells to the allocator to stop taking in account the memory given by ptr. The memory will not be released.

ovoid steal(void* ptr, Allocator* allocator)
Handles the memory given by ptr which was previouly handled by allocator. allocator looses the control of this memory

ovoid steal(Allocator* allocator)
Steals all pointers contained in allocator

oAllocatorNode* isMine(void* ptr)
Returns true iff ptr is handled by the allocator

ovoid freeAll()
Force all pointers contained in the allocator to be freed now. It considers the object_style given by alloc() and calls the Object destructor, if needed.

ostatic void* sysAlloc(int size)
System allocation. As system malloc function, but do an error if there is no more memory.

ostatic void* sysRealloc(void* ptr, int size)
System reallocation. As system realloc function, but do an error if there is no more memory.


This class has no child classes.
Author:
Ronan Collobert (collober@idiap.ch)
See Also:
Object

Alphabetic index HTML hierarchy of classes or Java



This page was generated with the help of DOC++.