WebAssembly / WebAssembly/component-model

null termination for strings

Open
#148 2 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
WebAssembly
Stars
1.4k
Forks
130
Avg merge
2d 1h
Merged PRs (30d)
15

Description

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.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the component model's current string representation and the role of cabi_realloc in component memory allocation. Compare the proposed null-termination behavior with the needs of legacy null-terminated APIs, then determine whether the specification change has a sufficiently defined scope and accepted outcome.

Written by the indexing model from the issue text.

Assessment

Tech stack
wasm
Domain
backend-api-design
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.