File tree Expand file tree Collapse file tree 2 files changed +11
-0
lines changed
tensorflow_lite_support/cc/task/text Expand file tree Collapse file tree 2 files changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -15,12 +15,18 @@ limitations under the License.
15
15
16
16
#include " tensorflow_lite_support/cc/task/text/nlclassifier/nl_classifier_c_api_common.h"
17
17
18
+ #include < memory>
18
19
19
20
#ifdef __cplusplus
20
21
extern " C" {
21
22
#endif // __cplusplus
22
23
23
24
void NLClassifierCategoriesDelete (Categories* categories) {
25
+ for (int i = 0 ; i < categories->size ; i++) {
26
+ // `strdup` obtains memory using `malloc` and the memory needs to be
27
+ // released using `free`.
28
+ free (categories->categories [i].text );
29
+ }
24
30
delete[] categories->categories ;
25
31
delete categories;
26
32
}
Original file line number Diff line number Diff line change @@ -70,6 +70,11 @@ void BertQuestionAnswererDelete(BertQuestionAnswerer* bert_question_answerer) {
70
70
}
71
71
72
72
void BertQuestionAnswererQaAnswersDelete (QaAnswers* qa_answers) {
73
+ for (int i = 0 ; i < qa_answers->size ; i++) {
74
+ // `strdup` obtains memory using `malloc` and the memory needs to be
75
+ // released using `free`.
76
+ free (qa_answers->answers [i].text );
77
+ }
73
78
delete[] qa_answers->answers ;
74
79
delete qa_answers;
75
80
}
You can’t perform that action at this time.
0 commit comments