add memory cleaning

This commit is contained in:
vms 2019-08-20 17:05:43 +02:00
parent e81ad192d3
commit f5ddb09b8b
2 changed files with 6 additions and 2 deletions

View File

@ -15,7 +15,7 @@ fi
# Build fluid WASM module # Build fluid WASM module
echo "Building to WASM..." echo "Building to WASM..."
docker-compose up --build docker-compose up --build
cp fluid.wasm wasm/ mv fluid.wasm wasm/
echo echo
# Run it all on 30000 port with default Fluence API # Run it all on 30000 port with default Fluence API

View File

@ -53,6 +53,7 @@ const char *invoke(char *str, int length) {
char *error = (char *)malloc(1024); char *error = (char *)malloc(1024);
const int error_size = snprintf(error, 1024, "%s given as the action field, but only `Post` and `Fetch` are supported", action); const int error_size = snprintf(error, 1024, "%s given as the action field, but only `Post` and `Fetch` are supported", action);
result = prepare_response(error, error_size); result = prepare_response(error, error_size);
free(error);
} }
return result; return result;
@ -141,5 +142,8 @@ const char *fetch_posts_request(const json_t *json) {
const int result_out_len = snprintf(result_out, result_len, "{ posts: \"%s\" }", result); const int result_out_len = snprintf(result_out, result_len, "{ posts: \"%s\" }", result);
return prepare_response(result_out, result_out_len); const char *prepared_response = prepare_response(result_out, result_out_len);
free(result_out);
return prepared_response;
} }