nitroAllocCString method

int nitroAllocCString(
  1. String s
)

Copies s into a <lib>_nitro_alloc'd NUL-terminated buffer — for values whose ownership transfers to native (e.g. callback string returns, which the bridge frees with its own free).

Implementation

int nitroAllocCString(String s) {
  final bytes = encodeCString(s);
  final p = nitroAlloc(bytes.length);
  writeBytes(p, bytes);
  return p;
}