1
0
mirror of https://gittea.dev/nova/th.git synced 2025-12-09 09:10:10 -05:00

indentation change, now using continue

This commit is contained in:
nova
2025-11-15 22:28:08 +01:00
parent 9a67b35ebe
commit 74166f7283

View File

@@ -63,46 +63,46 @@ void *thread_mid(){
mid_content = malloc(sizeof(file));
mid_content->file_name = "cannot open directory";
mid_file_count = 1;
} else {
pthread_mutex_unlock(&mutex_mid);
continue;
}
char *path = malloc(strlen(global_path)+1);
memcpy(path, global_path, strlen(global_path)+1);
char *path = malloc(strlen(global_path)+1);
memcpy(path, global_path, strlen(global_path)+1);
if (local_status & STATUS_RELOAD_DIRECTORY) {
unsigned long i = 0;
for (i = 0; i < mid_file_count; i++) {
free(mid_content[i].file_name);
}
free(mid_content);
mid_file_count = get_dir_size(path);
if (mid_file_count != 0) {
mid_content = malloc(mid_file_count * sizeof(file));
memset(mid_content, '\0', mid_file_count * sizeof(file));
get_dir_content(path, &mid_file_count, mid_content);
} else {
selected_file_current = 0;
mid_content = malloc(sizeof(file));
mid_content->file_type = 0;
mid_content->file_size = 0;
mid_content->permissions = 0;
mid_content->color_pair = 0;
mid_content->file_name = malloc(sizeof(char));
mid_content->file_name[0] = '\0';
mid_file_count = 0;
}
pthread_mutex_lock(&mutex_selection);
update_selected_file();
pthread_mutex_unlock(&mutex_selection);
if (local_status & STATUS_RELOAD_DIRECTORY) {
unsigned long i = 0;
for (i = 0; i < mid_file_count; i++) {
free(mid_content[i].file_name);
}
free(mid_content);
mid_file_count = get_dir_size(path);
if (mid_file_count != 0) {
mid_content = malloc(mid_file_count * sizeof(file));
memset(mid_content, '\0', mid_file_count * sizeof(file));
get_dir_content(path, &mid_file_count, mid_content);
} else {
selected_file_current = 0;
mid_content = malloc(sizeof(file));
mid_content->file_type = 0;
mid_content->file_size = 0;
mid_content->permissions = 0;
mid_content->color_pair = 0;
mid_content->file_name = malloc(sizeof(char));
mid_content->file_name[0] = '\0';
btm_status = local_status;
pthread_cond_signal(&cond_rgt);
pthread_cond_signal(&cond_btm);
mid_file_count = 0;
free(path);
}
pthread_mutex_lock(&mutex_selection);
update_selected_file();
pthread_mutex_unlock(&mutex_selection);
}
btm_status = local_status;
pthread_cond_signal(&cond_rgt);
pthread_cond_signal(&cond_btm);
free(path);
pthread_mutex_unlock(&mutex_mid);
}
pthread_exit(0);
@@ -118,30 +118,30 @@ void *thread_lft(){
lft_content = malloc(sizeof(file));
lft_content[0].file_name = "cannot open directory";
lft_file_count = 1;
} else {
char *path = malloc(strlen(global_path)+1);
memcpy(path, global_path, strlen(global_path)+1);
pthread_mutex_unlock(&mutex_lft);
continue;
}
char *path = malloc(strlen(global_path)+1);
memcpy(path, global_path, strlen(global_path)+1);
if (strcmp(path, "/") != 0) {
path[strrchr(path, '/')-path+1] = '\0';
path[strrchr(path, '/')-path] = '\0';
path[0] = '/';
if (strcmp(path, "/") != 0) {
path[strrchr(path, '/')-path+1] = '\0';
path[strrchr(path, '/')-path] = '\0';
path[0] = '/';
if (local_status & STATUS_RELOAD_DIRECTORY) {
lft_file_count = get_dir_size(path);
free(lft_content);
lft_content = malloc(lft_file_count * sizeof(file));
memset(lft_content, '\0', lft_file_count * sizeof(file));
get_dir_content(path, &lft_file_count, lft_content);
}
} else {
lft_file_count = 0;
if (local_status & STATUS_RELOAD_DIRECTORY) {
lft_file_count = get_dir_size(path);
free(lft_content);
lft_content = malloc(lft_file_count * sizeof(file));
memset(lft_content, '\0', lft_file_count * sizeof(file));
get_dir_content(path, &lft_file_count, lft_content);
}
free(path);
} else {
lft_file_count = 0;
}
free(path);
pthread_mutex_unlock(&mutex_lft);
}
pthread_exit(0);
@@ -244,11 +244,12 @@ void *thread_top(){
top_buffer = malloc(sizeof("cannot open directory"));
top_width = sizeof("cannot open directory");
top_buffer = "cannot open directory";
} else {
top_buffer = malloc(strlen(global_path)+1);
memcpy(top_buffer, global_path, strlen(global_path)+1);
top_width = strlen(top_buffer);
}
pthread_mutex_unlock(&mutex_top);
continue;
}
top_buffer = malloc(strlen(global_path)+1);
memcpy(top_buffer, global_path, strlen(global_path)+1);
top_width = strlen(top_buffer);
pthread_mutex_unlock(&mutex_top);
}