Skip to content

null termination for strings #148

@guybedford

Description

@guybedford

Strings in the component model are represented as pointers with a length and are allocated into component memory via the cabi_realloc function provided by the component.

When interfacing with APIs that work with "legacy" null-terminated strings, there is a need to perform an additional realloc to add the null termination to the string pointer, which can result in an unnecessary copy.

If, the component model were to explicitly define strings with null terminators for these kinds of legacy API use cases, that would avoid the need for this extra interop work.

It's come up a couple of times for me already now in practical component model workflows. I think it would be useful, but I don't have a very strong opinion on it. I thought it worth discussing as an option.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions