Skip to content

Commit

Permalink
update some free function
Browse files Browse the repository at this point in the history
  • Loading branch information
sunhailin-Leo committed Nov 24, 2023
1 parent c2fc870 commit 5e49044
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ Golang binding for https://github.com/zejunwang1/easytokenizer

### Version

* version 0.2.1
* Update some free function.

* version 0.2.0
* Fix `EncodeWithIds`, `WordPieceTokenize` API return error result.
* Add Github Workflows.
Expand Down
10 changes: 8 additions & 2 deletions tokenizer/tokenizer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,10 @@ std::string BasicTokenizer::normalize(const uint8_t* str) const
n = 0;
}
}
free(norm);
if (norm) {
free(norm);
norm = NULL;
}
return result;
}

Expand Down Expand Up @@ -370,7 +373,10 @@ SizeT Tokenizer::NFD_codepoint_number(const uint8_t* str) const
n = 0;
}
}
free(norm);
if (norm) {
free(norm);
norm = NULL;
}
return c;
}

Expand Down
2 changes: 2 additions & 0 deletions tokenizer/utf8proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -740,11 +740,13 @@ UTF8PROC_DLLEXPORT utf8proc_ssize_t utf8proc_map_custom(
result = utf8proc_decompose_custom(str, strlen, buffer, result, options, custom_func, custom_data);
if (result < 0) {
free(buffer);
buffer = NULL;
return result;
}
result = utf8proc_reencode(buffer, result, options);
if (result < 0) {
free(buffer);
buffer = NULL;
return result;
}
{
Expand Down

0 comments on commit 5e49044

Please sign in to comment.