Skip to content

Commit

Permalink
[Build] fix mem leak
Browse files Browse the repository at this point in the history
Code clean, fix mem leak case when using gstring util.

Signed-off-by: Jaeyun Jung <jy1210.jung@samsung.com>
  • Loading branch information
jaeyun-jung authored and anyj0527 committed Apr 29, 2024
1 parent 854896a commit a5a1e14
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
12 changes: 6 additions & 6 deletions Tizen.native/yolo_model_training/src/yolo_model_training.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,16 +127,16 @@ rename_images_filename (const gchar * images_path, const gchar * new_name,
g_return_if_fail (images_list != NULL);

for (i = 0; i < images_list->len; i++) {
GString *filename = g_string_new (NULL);
g_string_append_printf (filename, "%s_%03d.jpg", new_name, i);
gchar *filename = g_strdup_printf ("%s_%03d.jpg", new_name, i);

old_path = g_array_index (images_list, gchar *, i);
new_path = g_build_filename (images_path, filename->str, NULL);
new_path = g_build_filename (images_path, filename, NULL);
if (g_rename (old_path, new_path) == 0) {
dlog_print (DLOG_INFO, LOG_TAG, "rename: %s -> %s", old_path, new_path);
//need to set label
}
g_string_free (filename, TRUE);

g_free (new_path);
g_free (filename);
}
}

Expand Down Expand Up @@ -313,7 +313,7 @@ create_data_preprocess_pipeline (appdata_s * ad)
print_list_info (annotations_list, ad->label2);

/** The person using the model needs to know how to construct the model
and what data formats are required.
and what data formats are required.
The performance of the model is related to the construction of the model
and the preprocessed data. */
label_file = create_label_file (annotations_list);
Expand Down
8 changes: 4 additions & 4 deletions Tizen.platform/Vivante_pipeline_experiments/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ int main (int argc, char *argv[]){
if (enable_vnn_inception){
vnn_inception_nb = g_strdup_printf ("/usr/share/dann/inception-v3.nb");
vnn_inception_so = g_strdup_printf ("/usr/share/vivante/inceptionv3/libinceptionv3.so");
g_string_append_printf (pipeline,
g_string_append_printf (pipeline,
" t. ! queue ! videoscale ! "
"video/x-raw,format=RGB,width=%d,height=%d ! "
"tensor_converter ! "
Expand All @@ -176,7 +176,7 @@ int main (int argc, char *argv[]){
if (enable_vnn_yolo){
vnn_yolo_nb = g_strdup_printf ("/usr/share/dann/yolo-v3.nb");
vnn_yolo_so = g_strdup_printf ("/usr/share/vivante/yolov3/libyolov3.so");
g_string_append_printf (pipeline,
g_string_append_printf (pipeline,
" t. ! queue ! videoscale ! "
"video/x-raw,format=RGB,width=%d,height=%d ! "
"tensor_converter ! "
Expand All @@ -192,7 +192,7 @@ int main (int argc, char *argv[]){

if (enable_tflite_inception){
tflite_inception_model = g_strdup_printf ("/usr/share/vivante/inception_v3_quant.tflite");
g_string_append_printf (pipeline,
g_string_append_printf (pipeline,
" t. ! queue ! videoscale ! "
"video/x-raw,format=RGB,width=%d,height=%d ! "
"tensor_converter ! "
Expand Down Expand Up @@ -276,7 +276,7 @@ int main (int argc, char *argv[]){
g_free (vnn_yolo_so);
g_free (tflite_inception_model);

g_string_free (pipeline, FALSE);
g_string_free (pipeline, TRUE);

app_finish_time = g_get_real_time ();
print_profile ();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ main (int argc, char **argv)
_check_cond_err (annotations_list != NULL);

/** The person using the model needs to know how to construct the model
and what data formats are required.
and what data formats are required.
The performance of the model is related to the construction of the model
and the preprocessed data. */

Expand Down Expand Up @@ -206,7 +206,7 @@ main (int argc, char **argv)
"tensor_mux name=mux sync-mode=nosync ! "
"datareposink location=yolo.data json=yolo.json", path,
label_file);
g_string_free (filename, FALSE);
g_string_free (filename, TRUE);
g_free (images_path);
g_free (path);

Expand Down Expand Up @@ -304,16 +304,16 @@ rename_images_filename (const gchar * images_path, const gchar * new_name,
g_return_if_fail (images_list != NULL);

for (i = 0; i < images_list->len; i++) {
GString *filename = g_string_new (NULL);
g_string_append_printf (filename, "%s_%03d.png", new_name, i);
gchar *filename = g_strdup_printf ("%s_%03d.png", new_name, i);

old_path = g_array_index (images_list, gchar *, i);
new_path = g_build_filename (images_path, filename->str, NULL);
new_path = g_build_filename (images_path, filename, NULL);
if (g_rename (old_path, new_path) == 0) {
_print_log ("rename: %s -> %s", old_path, new_path);
}

g_string_free (filename, FALSE);
g_free (new_path);
g_free (filename);
}
}

Expand Down

0 comments on commit a5a1e14

Please sign in to comment.