Changeset 3a038fa for doc/theses/mubeen_zulfiqar_MMath/allocator.tex
- Timestamp:
- Feb 23, 2022, 10:31:12 AM (3 years ago)
- Branches:
- ADT, ast-experimental, enum, master, pthread-emulation, qualifiedEnum
- Children:
- cc7bbe6
- Parents:
- f53afafb
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
doc/theses/mubeen_zulfiqar_MMath/allocator.tex
rf53afafb r3a038fa 118 118 We added a few more features and routines to the allocator's C interface that can make the allocator more usable to the programmers. THese features will programmer more control on the dynamic memory allocation. 119 119 120 \subsection{Out of Memory} 121 122 Most allocators use @nullptr@ to indicate an allocation failure, specifically out of memory; 123 hence the need to return an alternate value for a zero-sized allocation. 124 The alternative is to abort a program when out of memory. 125 In theory, notifying the programmer allows recovery; 126 in practice, it is almost impossible to gracefully when out of memory, so the cheaper approach of returning @nullptr@ for a zero-sized allocation is chosen. 127 128 120 129 \subsection{\lstinline{void * aalloc( size_t dim, size_t elemSize )}} 121 130 @aalloc@ is an extension of malloc. It allows programmer to allocate a dynamic array of objects without calculating the total size of array explicitly. The only alternate of this routine in the other allocators is calloc but calloc also fills the dynamic memory with 0 which makes it slower for a programmer who only wants to dynamically allocate an array of objects without filling it with 0.
Note: See TracChangeset
for help on using the changeset viewer.