add to allocate type_tag

This commit is contained in:
vms 2022-04-20 18:36:09 +03:00
parent e5a72b8d14
commit a79de2217e
2 changed files with 9 additions and 6 deletions

View File

@ -7,8 +7,7 @@ RUN apt-get update \
make \
cargo
RUN curl -L https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-10/wasi-sdk-10.0-linux.tar.gz | tar xz --strip-components=1 -C /
RUN cargo install fcli
RUN curl -L https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-11/wasi-sdk-11.0-linux.tar.gz | tar xz --strip-components=1 -C /
VOLUME /code
WORKDIR /code

View File

@ -18,7 +18,11 @@ void init() {
int g_isInited = 0;
void* allocate(size_t size) {
void* allocate(size_t size, size_t _type_tag) {
if (size == 0 || size + 1 == 0) {
return 0;
}
// allocate one more byte for adding the \n symbol that indicated the end of request
return zmalloc(size + 1);
}
@ -75,7 +79,7 @@ void clean_client_buffer(client *c) {
}
char *write_response(client *c, size_t *response_size) {
char *response = allocate(c->bufpos + c->reply_bytes);
char *response = allocate(c->bufpos + c->reply_bytes, 1);
*response_size = 0;
memcpy(response, c->buf, c->bufpos);