Skip to content
StrDeinitAlloc

StrDeinitAlloc

Description

Deinitialize a copied Str through an explicit allocator context.

This is primarily used by generic containers that own copied Str values and need allocator-aware copy cleanup callbacks.

Parameters

Name Direction Description
copy in,out Pointer to the Str object to deinitialize.
alloc in Allocator context for the owning container. The callback must use this allocator (not the bound one) for the underlying free.

Success

Returns to the caller. The byte buffer of *copy has been freed via alloc; length, capacity, and data are reset. The struct is left in a deinited state consistent with the container’s deep-copy contract.

Failure

Does not return if copy or alloc are NULL or otherwise violate the callback contract; aborts via LOG_FATAL.

Usage example (Cross-references)

Usage examples (Cross-references)
    }
    
    void StrDeinitAlloc(void *copy, const Allocator *alloc) {
        (void)alloc;
        StrDeinit((Str *)copy);
        ValidateStr(s);
    
        Strs sv     = VecInitWithDeepCopy(NULL, StrDeinitAlloc);
        size keylen = ZstrLen(key);
            KvConfigCompare,                                                                                               \
            StrInitCopyAlloc,                                                                                              \
            StrDeinitAlloc,                                                                                                \
            StrInitCopyAlloc,                                                                                              \
            StrDeinitAlloc                                                                                                 \
            StrDeinitAlloc,                                                                                                \
            StrInitCopyAlloc,                                                                                              \
            StrDeinitAlloc                                                                                                 \
        )
Last updated on