feat: add code style rules
This commit is contained in:
+15
-16
@@ -2,28 +2,27 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
fzl_token_t *fzl_mktoken(
|
||||
const fzl_toktype_t type, uint16_t from, uint16_t to,
|
||||
void *value, size_t value_len)
|
||||
fzl_token_t *fzl_mktoken(const fzl_toktype_t type, uint16_t from, uint16_t to,
|
||||
void *value, size_t value_len)
|
||||
{
|
||||
void *valholder = malloc(value_len);
|
||||
memcpy(valholder, value, value_len);
|
||||
void *valholder = malloc(value_len);
|
||||
memcpy(valholder, value, value_len);
|
||||
|
||||
fzl_token_t *token = malloc(sizeof(fzl_token_t));
|
||||
token->type = type;
|
||||
token->i0 = from;
|
||||
token->i1 = to;
|
||||
token->store_value = value_len > 0;
|
||||
token->value = valholder;
|
||||
token->value_sz = value_len;
|
||||
fzl_token_t *token = malloc(sizeof(fzl_token_t));
|
||||
token->type = type;
|
||||
token->i0 = from;
|
||||
token->i1 = to;
|
||||
token->store_value = value_len > 0;
|
||||
token->value = valholder;
|
||||
token->value_sz = value_len;
|
||||
|
||||
return token;
|
||||
return token;
|
||||
}
|
||||
|
||||
// Free allocated token
|
||||
void fzl_freetoken(fzl_token_t *tok)
|
||||
{
|
||||
if (tok->store_value) free(tok->value);
|
||||
free(tok);
|
||||
if (tok->store_value)
|
||||
free(tok->value);
|
||||
free(tok);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user