summaryrefslogtreecommitdiff
path: root/mem/docs/allocator.9.scd
diff options
context:
space:
mode:
Diffstat (limited to 'mem/docs/allocator.9.scd')
-rw-r--r--mem/docs/allocator.9.scd15
1 files changed, 8 insertions, 7 deletions
diff --git a/mem/docs/allocator.9.scd b/mem/docs/allocator.9.scd
index c70156a..2f196ad 100644
--- a/mem/docs/allocator.9.scd
+++ b/mem/docs/allocator.9.scd
@@ -34,29 +34,30 @@ When working with allocators, proper care must be taken in regards of the limita
The *mem_alloc()* function is used to dispatch the allocation method call to the underlying implementation of the allocator. This function takes the following arguments:
- _self_ The allocator that should be used
- _n_ The minimal amount of char-sized units of memory the allocated region should span
+ - _self_ The allocator that should be used
+ - _n_ The minimal amount of char-sized units of memory the allocated region should span
## Reallocation
The *mem_realloc()* function is used to dispatch the reallocation method call to the underlying implemention of the allocator. Reallocation consists in modifying the size of a previously allocated region. *mem_realloc()* takes the following arguments:
- _self_ The allocator that should be used
- _ptr_ The previously allocated region of memory, as returned by a previous call to *mem_alloc()* or *mem_realloc()*
- _n_ The new size of the allocated region, in char-sized units
+ - _self_ The allocator that should be used
+ - _ptr_ The previously allocated region of memory, as returned by a previous call to *mem_alloc()* or *mem_realloc()*
+ - _n_ The new size of the allocated region, in char-sized units
## Freeing
The *mem_free()* function is used to dispatch the free method call to the underlying imprlemention of the allocator. Freeing consists in indicating to the allocator that a region is no longer in use and that it can be reclaimed; this reclaimed memory could then, for example, be used as the result of other allocation requests by *mem_alloc()* or *mem_realloc()*. *mem_free()* takes the following arguments:
- _self_ The allocator that should be used
- _ptr_ The previously allocated region of memory, as returned by a previous call to *mem_alloc()* or *mem_realloc()*
+ - _self_ The allocator that should be used
+ - _ptr_ The previously allocated region of memory, as returned by a previous call to *mem_alloc()* or *mem_realloc()*
Proper care should be taken to only free region of memory that have been allocated by a previous call to the same allocator, this includes double frees.
# RETURN VALUES
*mem_alloc()* returns the beginning of the allocated region on success, nil on error or 0 provided.
+
*mem_realloc()* returns the beginning of the reallocated region on success, nil on error or 0 provided. Note: in case nil, the passed region is freed.
# CODE REFERENCES