Skip to content

Commit

Permalink
cleanup: host takes ownership of memory blocks it gets as arguments f…
Browse files Browse the repository at this point in the history
…or extism functions
  • Loading branch information
zshipko committed Sep 19, 2024
1 parent 96aa0ed commit c1c7d44
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 10 deletions.
6 changes: 0 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,6 @@ static const char Greeting[] = "Hello, ";
int32_t EXTISM_EXPORTED_FUNCTION(greet) {
ExtismHandle key = extism_alloc_buf_from_sz("user");
ExtismHandle value = extism_config_get(key);
extism_free(key);

if (value == 0) {
ExtismHandle err = extism_alloc_buf_from_sz("Invalid key");
Expand Down Expand Up @@ -233,11 +232,6 @@ int32_t EXTISM_EXPORTED_FUNCTION(count) {
// Set the variable
extism_var_set(key, value);

// Free key/value, vars are stored on the host side so they remain
// available between calls
extism_free(value);
extism_free(key);

return 0;
}
```
Expand Down
4 changes: 0 additions & 4 deletions extism-pdk.h
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,6 @@ void extism_log(const char *s, const size_t len, const ExtismLog level) {
extism_log_error(buf);
break;
}
extism_free(buf);
}

// Write zero-terminated string to Extism log
Expand Down Expand Up @@ -479,7 +478,6 @@ void extism_error_set_buf_from_sz(const char *message) {
ExtismHandle extism_config_get_buf(const char *name, const size_t nameLen) {
ExtismHandle key = extism_alloc_buf(name, nameLen);
ExtismHandle value = extism_config_get(key);
extism_free(key);
return value;
}

Expand All @@ -493,7 +491,6 @@ ExtismHandle extism_config_get_buf_from_sz(const char *name) {
ExtismHandle extism_var_get_buf(const char *name, const size_t nameLen) {
ExtismHandle key = extism_alloc_buf(name, nameLen);
ExtismHandle value = extism_var_get(key);
extism_free(key);
return value;
}

Expand All @@ -508,7 +505,6 @@ void extism_var_set_buf(const char *name, const size_t nameLen,
const ExtismHandle value) {
ExtismHandle key = extism_alloc_buf(name, nameLen);
extism_var_set(key, value);
extism_free(key);
}

// store a var from a sz key
Expand Down

0 comments on commit c1c7d44

Please sign in to comment.