GAsyncQueue *reg_queue;
GMutex scan_req_mutex;
-static void __msc_clear_file_list(GArray *path_array);
+static void __msc_clear_file_list(GPtrArray *path_array);
static bool __msc_is_stop_needed()
{
GDir *dir = NULL;
GError *error = NULL;
const char *name;
- GArray *dir_array = NULL;
+ GPtrArray *dir_array = NULL;
char *current_path = NULL;
char *path = NULL;
int (*scan_function)(sqlite3 *, const char*, const char*, uid_t) = NULL;
- dir_array = g_array_new(FALSE, FALSE, sizeof(char*));
+ dir_array = g_ptr_array_new();
if (!dir_array) {
MS_SAFE_FREE(start_path);
return MS_MEDIA_ERR_OUT_OF_MEMORY;
}
- g_array_append_val(dir_array, start_path);
+ g_ptr_array_add(dir_array, start_path);
scan_function = (check_exists == false) ? ms_insert_item_batch : ms_validate_item;
goto STOP_SCAN;
}
- current_path = g_array_index(dir_array , char*, 0);
- g_array_remove_index(dir_array, 0);
+ current_path = g_ptr_array_index(dir_array, 0);
+ g_ptr_array_remove_index(dir_array, 0);
if (ms_check_scan_ignore(current_path, uid) != MS_MEDIA_ERR_NONE) {
MS_DBG_ERR("%s is ignore", current_path);
MS_SAFE_FREE(path);
} else {
if (is_recursive) {
- g_array_append_val(dir_array, path);
+ g_ptr_array_add(dir_array, path);
} else {
ms_insert_folder(handle, storage_id, path, uid);
MS_SAFE_FREE(path);
return FALSE;
}
-static void __msc_clear_file_list(GArray *path_array)
+static void __msc_clear_file_list(GPtrArray *path_array)
{
if (!path_array)
return;
- g_array_set_clear_func(path_array, g_free);
- g_array_free(path_array, TRUE);
+ g_ptr_array_free(path_array, TRUE);
}
-static int __msc_make_file_list(char *file_path, GArray **path_array, uid_t uid)
+static int __msc_make_file_list(char *file_path, GPtrArray **path_array, uid_t uid)
{
FILE *fp = NULL;
char buf[MS_FILE_PATH_LEN_MAX] = {0,};
memset(buf, 0x0, MS_FILE_PATH_LEN_MAX);
/* This is an array for storing the path of insert datas*/
- *path_array = g_array_new(FALSE, FALSE, sizeof(char *));
+ *path_array = g_ptr_array_new_with_free_func(g_free);
if (*path_array == NULL) {
MS_DBG_ERR("g_array_new failed");
ret = MS_MEDIA_ERR_OUT_OF_MEMORY;
continue;
}
/* insert getted path to the list */
- if (g_array_append_val(*path_array, path) == NULL) {
- MS_DBG_ERR("g_array_append_val failed");
- ret = MS_MEDIA_ERR_OUT_OF_MEMORY;
- goto FREE_RESOURCE;
- }
+ g_ptr_array_add(*path_array, path);
+
}
if (fp) fclose(fp);
return ret;
}
-static int __msc_batch_insert(int pid, GArray *path_array, uid_t uid)
+static int __msc_batch_insert(int pid, GPtrArray *path_array, uid_t uid)
{
int ret = MS_MEDIA_ERR_NONE;
sqlite3 *handle = NULL;
ms_batch_commit_enable(true, false, true, pid);
for (i = 0; i < path_array->len; i++) {
- insert_path = g_array_index(path_array, char*, i);
+ insert_path = g_ptr_array_index(path_array, i);
memset(storage_id, 0x0, MS_UUID_SIZE);
if (ms_get_storage_id(handle, insert_path, storage_id, uid) != MS_MEDIA_ERR_NONE) {
{
int ret = MS_MEDIA_ERR_NONE;
ms_comm_msg_s *register_data = NULL;
- GArray *path_array = NULL;
+ GPtrArray *path_array = NULL;
while (1) {
register_data = g_async_queue_pop(reg_queue);