Skip to content

AllocatorBind

Description

Prepare an allocator for object binding. Missing allocation callbacks are filled from the default heap allocator and the runtime state pointer is reset so each bound object starts with a fresh allocator instance state.

Parameters

Name Direction Description
alloc in Allocator template to bind

Success

Returns a bound allocator descriptor.

Failure

Function cannot fail.

Usage example (Cross-references)

Usage examples (Cross-references)
    }
    
    Allocator AllocatorBind(Allocator alloc) {
        Allocator heap = HeapAllocator();
        graph->alignment            = 0;
        AllocatorUnbind(&graph->allocator);
        graph->allocator   = AllocatorBind(DefaultAllocator());
        graph->type_anchor = NULL;
        graph->__magic     = 0;
        vec->data        = NULL;
        vec->alignment   = alignment;
        vec->allocator   = AllocatorBind(allocator);
        vec->__magic     = MISRA_VEC_MAGIC;
    }
        vec->capacity = 0;
        AllocatorUnbind(&vec->allocator);
        vec->allocator = AllocatorBind(DefaultAllocator());
    }
        list->length      = 0;
        AllocatorUnbind(&list->allocator);
        list->allocator = AllocatorBind(DefaultAllocator());
    }
        bitvec->byte_size = 0;
        AllocatorUnbind(&bitvec->allocator);
        bitvec->allocator = AllocatorBind(DefaultAllocator());
    }
        }
    
        scratch = AllocatorBind(bv1->allocator);
    
        // Dynamic programming matrix
        map->policy.next_index      = NULL;
        map->policy.max_probe_count = 0;
        map->allocator              = AllocatorBind(DefaultAllocator());
        map->__magic                = 0;
    }
         .states            = NULL,                                                                                        \
         .policy            = validate_map_policy_copy((policy_value)),                                                    \
         .allocator         = AllocatorBind(DefaultAllocator()),                                                           \
         .__magic           = MISRA_MAP_MAGIC}
         .data        = NULL,                                                                                              \
         .alignment   = (aln),                                                                                             \
         .allocator   = AllocatorBind((alloc)),                                                                            \
         .__magic     = MISRA_VEC_MAGIC}
         .copy_deinit = (GenericCopyDeinit)(cd),                                                                           \
         .length      = 0,                                                                                                 \
         .allocator   = AllocatorBind((alloc)),                                                                            \
         .__magic     = MISRA_LIST_MAGIC}
                .data      = NULL,                                                                                         \
                .byte_size = 0,                                                                                            \
                .allocator = AllocatorBind(DefaultAllocator()),                                                            \
                .__magic   = MISRA_BITVEC_MAGIC                                                                            \
            })
                .data      = NULL,                                                                                         \
                .byte_size = 0,                                                                                            \
                .allocator = AllocatorBind((alloc)),                                                                       \
                .__magic   = MISRA_BITVEC_MAGIC                                                                            \
            })
                       .data      = NULL,                                                                                  \
                       .byte_size = 0,                                                                                     \
                       .allocator = AllocatorBind(DefaultAllocator()),                                                     \
                       .__magic   = MISRA_BITVEC_MAGIC})
    #    define BitVecInit_1(alloc)                                                                                        \
                       .data      = NULL,                                                                                  \
                       .byte_size = 0,                                                                                     \
                       .allocator = AllocatorBind((alloc)),                                                                \
                       .__magic   = MISRA_BITVEC_MAGIC})
    #endif
         .mutation_epoch       = 0,                                                                                       \
         .alignment            = (aln),                                                                                   \
         .allocator            = AllocatorBind((alloc)),                                                                  \
         .type_anchor          = NULL,                                                                                    \
         .__magic              = MISRA_GRAPH_MAGIC}
Last updated on