- *item_list = calloc(current_max_size, sizeof(char*));
- if (*item_list == NULL) {
- fclose(fp);
- SAFE_FREE(*item_list);
- content_error("Out of Memory");
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
- memset(tmp_str, 0, sizeof(tmp_str));
-
- while (fgets(tmp_str, MAX_QUERY_SIZE, fp) != NULL) {
- memset(repl_item, 0, sizeof(repl_item));
- _media_content_replace_path(tmp_str, repl_item);
- tmp_str_len = strlen(repl_item);
- if (tmp_str_len > 0 && repl_item[tmp_str_len - 1] == '\n')
- repl_item[tmp_str_len - 1] = '\0';
-
- tmp_str_len = strlen(repl_item);
-
- if (tmp_str_len > 0 && repl_item[0] != '#') {
- if (!(current_index < (current_max_size - 1))) {
- current_max_size += PLAYLIST_ARRAY_EXPAND;
- char **tmp_ptr = calloc(current_max_size, sizeof(char*));
- if (tmp_ptr == NULL) {
- __media_playlist_destroy_import_item(*item_list, current_index);
- content_error("Out of Memory");
- fclose(fp);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
- memmove(tmp_ptr, *item_list, sizeof(char*) * current_index);
- SAFE_FREE(*item_list);
- *item_list = tmp_ptr;
- }
-
- (*item_list)[current_index] = malloc(tmp_str_len + 1);
- if ((*item_list)[current_index] == NULL) {
- __media_playlist_destroy_import_item(*item_list, current_index);
- content_error("Out of Memory");
- fclose(fp);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
- memset((*item_list)[current_index], 0, tmp_str_len + 1);
- memmove((*item_list)[current_index], repl_item, tmp_str_len);
-
- current_index += 1;
- }