Matias De lellis avatar Matias De lellis committed feda2fc

fix C binding for get_*_labels() functions

Comments (3)

Files changed (2)

bindings/c/taginfo_c.cc

                                      int *labels_length) {
     const Info *i = reinterpret_cast<const Info *>(info);
     StringList list = i->get_track_labels_list();
-
+    
     if(list.isEmpty())
         cout << "list not there"  << endl;
     int len = list.size();
         j++;
     }
     *labels_length = len;
-	return labels;
+    return labels;
 }
 void taginfo_info_set_track_labels(TagInfo_Info *info,
                                    char** labels, int labels_length) {
                                      int *labels_length) {
     const Info *i = reinterpret_cast<const Info *>(info);
     StringList list = i->get_album_labels_list();
-
+    
     if(list.isEmpty())
         cout << "list not there"  << endl;
     int len = list.size();
         j++;
     }
     *labels_length = len;
-	return labels;
+    return labels;
 }
 void taginfo_info_set_album_labels(TagInfo_Info *info,
                                    char** labels, int labels_length) {
     i->set_album_labels_list(list);
 }
 
-char **taginfo_info_get_artist_labels(const TagInfo_Info *info,
+char** taginfo_info_get_artist_labels(const TagInfo_Info *info,
                                       int * labels_length) {
     const Info *i = reinterpret_cast<const Info *>(info);
     StringList list = i->get_artist_labels_list();
-
+    
     if(list.isEmpty())
         cout << "list not there"  << endl;
     int len = list.size();
         j++;
     }
     *labels_length = len;
-	return labels;
+    return labels;
 }
 void taginfo_info_set_artist_labels(TagInfo_Info *info,
                                     char** labels, int labels_length) {

tests/ctest_write/main.c

     if(info == NULL)
         return 1; //EXIT_FAILURE
     taginfo_info_set_title(info, TESTTITLE);
+    taginfo_info_set_albumartist(info, TESTTITLE "äé");
     int labels_length = 2;
     char** labels = malloc(labels_length * sizeof(char*));
     labels[0] = strdup("label 1 äöü");
     taginfo_info_write(info);
     taginfo_info_free(info);
     info = taginfo_info_factory_make(target);
+    int j = 0;
     if(taginfo_info_read(info)) {
-        char* name = taginfo_info_get_title(info);
-        
         int out_labels_length = 0;
         char** out_labels = taginfo_info_get_artist_labels(info, &out_labels_length);
-
-        if(strcmp(name, TESTTITLE) == 0 &&
-           check_list_equal(labels, labels_length, out_labels, out_labels_length)) {
+        
+        if(strcmp(taginfo_info_get_title(info), TESTTITLE) == 0 &&
+           check_list_equal(labels, labels_length, out_labels, out_labels_length) &&
+           strcmp(taginfo_info_get_albumartist(info), (TESTTITLE "äé")) == 0) {
             
-            free(name);
+            for(j = 0; j < labels_length; j++) {
+                free(labels[j]);
+                free(out_labels[j]);
+            }
             taginfo_info_free(info);
             return 0; //EXIT_SUCCESS
         }
-        free(name);
+        for(j = 0; j < labels_length; j++) {
+            free(labels[j]);
+            free(out_labels[j]);
+        }
         taginfo_info_free(info);
         return 1; //EXIT_FAILURE
     }
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.