exaloop / exaloop/codon

Resource ownership rules when integrating with C++

Open
#736 5 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
16.8k
Forks
603
Avg merge
4d 23h
Merged PRs (30d)
6

Description

These questions apply to both embedded JIT mode as well as to "as a shared library" mode.

On Codon side:
```
extern
def f1(s:str) -> str
```

On C++ side

```

struct CodonString {
seq_int_t len;
char *str;
};

extern "C" CodonString f2( CodonString s);
```

Questions:
1. C++ side invokes f1:
* Who owns string memory in incoming argument `s` ? If it's codon - can C++ "ref count" it and later unref or it must copy ?
* Who owns string memory of return string? C++ has generated this string by allocating it with `seq_alloc_atomic`. But who will release it and when?

2. Codon side invokes f2:
* Who owns string memory in `s`?
* Who owns string memory of return string?

These rules must be explained and documented.

Thanks!

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.