AllocatorAlloc
Description
Allocate memory through an allocator. The allocator effort policy controls how many attempts are made before the allocation is reported as failed.
Parameters
| Name | Direction | Description |
|---|---|---|
alloc |
in,out | Allocator used for the allocation |
bytes |
in | Number of bytes to allocate |
alignment |
in | Required alignment in bytes |
zeroed |
in | Whether the allocated region must be zero-initialized |
Success
Returns a writable pointer to allocated memory.
Failure
Returns NULL when allocation fails or allocator is invalid.
Usage example (Cross-references)
Usage examples (Cross-references)
- In
Sys.c:47:
}
env_var = (char *)AllocatorAlloc(&allocator, requiredSize, 1, false);
if (!env_var) {
return NULL;- In
Memory.c:159:
len++;
char *new_str = (char *)AllocatorAlloc(&alloc, len + 1, 1, false);
if (!new_str) {
LOG_SYS_ERROR("allocator allocate failed");- In
Allocator.c:163:
}
void *AllocatorAlloc(Allocator *alloc, size bytes, size alignment, bool zeroed) {
size attempts;
size try_idx;- In
Io.c:2964:
}
u8 *buffer = (u8 *)AllocatorAlloc(&o->allocator, byte_len * sizeof(u8), 1, true);
if (!buffer) {- In
Graph.c:121:
static void *graph_alloc_node_data(GenericGraph *graph, size item_size) {
graph_validate_alignment(graph);
return AllocatorAlloc(&graph->allocator, item_size, graph_node_data_alignment(graph), true);
}- In
List.c:12:
static inline GenericListNode *alloc_list_node(GenericList *list) {
return AllocatorAlloc(&list->allocator, sizeof(GenericListNode), list_alloc_alignment(), true);
}- In
List.c:20:
static inline void *alloc_list_item(GenericList *list, u64 item_size) {
return AllocatorAlloc(&list->allocator, item_size, list_alloc_alignment(), true);
}- In
List.c:200:
item_count = list->length;
data = AllocatorAlloc(&list->allocator, item_size * item_count, list_alloc_alignment(), false);
if (!data) {
return false;- In
BitVec.c:45:
}
result.data = (u8 *)AllocatorAlloc(&result.allocator, BITVEC_BYTES_FOR_BITS(cap), 1, true);
if (!result.data) {
return result;- In
BitVec.c:1421:
// Dynamic programming matrix
u64 *prev_row = AllocatorAlloc(&scratch, (len2 + 1) * sizeof(u64), _Alignof(u64), false);
u64 *curr_row = AllocatorAlloc(&scratch, (len2 + 1) * sizeof(u64), _Alignof(u64), false);- In
BitVec.c:1422:
// Dynamic programming matrix
u64 *prev_row = AllocatorAlloc(&scratch, (len2 + 1) * sizeof(u64), _Alignof(u64), false);
u64 *curr_row = AllocatorAlloc(&scratch, (len2 + 1) * sizeof(u64), _Alignof(u64), false);
if (!prev_row || !curr_row) {- In
Map.c:539:
old_capacity = map->capacity;
new_entries = AllocatorAlloc(&map->allocator, new_capacity * entry_size, map_storage_alignment(), true);
new_states = AllocatorAlloc(&map->allocator, new_capacity * sizeof(u8), map_storage_alignment(), true);- In
Map.c:540:
new_entries = AllocatorAlloc(&map->allocator, new_capacity * entry_size, map_storage_alignment(), true);
new_states = AllocatorAlloc(&map->allocator, new_capacity * sizeof(u8), map_storage_alignment(), true);
if (!new_entries || !new_states) {- In
Map.c:993:
hash = map_hash_key(map, key, key_size);
temp_entry = AllocatorAlloc(&map->allocator, entry_size, map_storage_alignment(), true);
if (!temp_entry) {
return false;- In
Map.c:1051:
if (map->value_copy_init) {
temp_value = AllocatorAlloc(&map->allocator, value_size, map_storage_alignment(), true);
if (!temp_value) {
return false;- In
Proc.c:145:
Allocator allocator = DefaultAllocator();
SysProc *proc = (SysProc *)AllocatorAlloc(&allocator, sizeof(SysProc), _Alignof(SysProc), true);
if (!proc) {- In
Proc.c:228:
Allocator allocator = DefaultAllocator();
SysProc *proc = (SysProc *)AllocatorAlloc(&allocator, sizeof(SysProc), _Alignof(SysProc), true);
if (!proc) {- In
Mutex.c:32:
SysMutex *SysMutexCreate(void) {
Allocator allocator = DefaultAllocator();
SysMutex *m = (SysMutex *)AllocatorAlloc(&allocator, sizeof(SysMutex), _Alignof(SysMutex), true);
if (!m) {- In
File.c:80:
}
buffer = (char *)AllocatorAlloc(&allocator, 4, 1, true);
if (!buffer) {
unlink(path);
Last updated on