Skip to content
StrInitCopyAlloc

StrInitCopyAlloc

Description

Copy a Str through an explicit destination allocator context.

This is primarily used by generic containers during deep-copy insertion.

Parameters

Name Direction Description
dst out Destination Str.
src in Source Str.
alloc in Allocator context for the owning destination container.

Success

Returns true. *dst is a deep copy of *src with the byte buffer allocated through alloc (not the source’s allocator). Length matches src->length.

Failure

Returns false on allocation failure for the destination buffer. *dst is left in an initialized- but-empty state.

Usage example (Cross-references)

Usage examples (Cross-references)
        }
    
        return StrInitCopyAlloc(dst, src, &src->allocator);
    }
    }
    
    bool StrInitCopyAlloc(void *dst_ptr, const void *src_ptr, const Allocator *alloc) {
        Str             *dst             = (Str *)dst_ptr;
        const Str       *src             = (const Str *)src_ptr;
            KvConfigCompare,                                                                                               \
            KvConfigCompare,                                                                                               \
            StrInitCopyAlloc,                                                                                              \
            StrDeinitAlloc,                                                                                                \
            StrInitCopyAlloc,                                                                                              \
            StrInitCopyAlloc,                                                                                              \
            StrDeinitAlloc,                                                                                                \
            StrInitCopyAlloc,                                                                                              \
            StrDeinitAlloc                                                                                                 \
        )
Last updated on