removal of file_size_width
This commit is contained in:
42
threading.c
42
threading.c
@@ -21,13 +21,13 @@ pthread_cond_t cond_wait;
|
||||
volatile char wait_count; /* this is used to determine how many threads are waiting for cont_wait */
|
||||
|
||||
file *rgt_content;
|
||||
volatile file *mid_content;
|
||||
file *mid_content;
|
||||
file *lft_content;
|
||||
char *rgt_buffer; /* used for file previews, unlike rgt_content, which is used for directory previews */
|
||||
char *btm_buffer;
|
||||
char *top_buffer; /* current path */
|
||||
|
||||
file *file_current;
|
||||
volatile file *file_current;
|
||||
|
||||
|
||||
unsigned long rgt_file_count;
|
||||
@@ -43,14 +43,13 @@ extern unsigned int terminal_width;
|
||||
|
||||
|
||||
void *thread_mid(void *data){
|
||||
volatile unsigned int status = *(unsigned int*)data;
|
||||
unsigned int status = *(unsigned int*)data;
|
||||
pthread_mutex_lock(&mutex_mid);
|
||||
|
||||
|
||||
char *path;
|
||||
if((path=getcwd(NULL, 0)) == NULL) {
|
||||
mid_content = malloc(sizeof(file));
|
||||
mid_content->file_name_width = sizeof("cannot open directory");
|
||||
mid_content->file_name = "cannot open directory";
|
||||
mid_file_count = 1;
|
||||
} else {
|
||||
@@ -58,10 +57,10 @@ void *thread_mid(void *data){
|
||||
|
||||
if (status & STATUS_RELOAD_DIRECTORY) {
|
||||
free(mid_content);
|
||||
mid_file_count = (unsigned long)get_dir_size(path);
|
||||
mid_file_count = get_dir_size(path);
|
||||
if (mid_file_count > 0) {
|
||||
mid_content = malloc(mid_file_count * sizeof(file));
|
||||
memset(mid_content, ' ', 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;
|
||||
@@ -71,18 +70,14 @@ void *thread_mid(void *data){
|
||||
mid_content->file_size = 0;
|
||||
mid_content->permissions = 0;
|
||||
mid_content->color_pair = 0;
|
||||
mid_content->file_name_width = sizeof("empty dir");
|
||||
mid_content->file_name = "empty dir";
|
||||
/*
|
||||
|
||||
file_current->file_name = mid_content->file_name;
|
||||
file_current->file_name_width = mid_content->file_name_width;
|
||||
file_current->file_size = mid_content->file_size;
|
||||
file_current->file_type = mid_content->file_type;
|
||||
file_current->color_pair = mid_content->color_pair;
|
||||
file_current->permissions = mid_content->permissions;
|
||||
file_current->status = mid_content->status;
|
||||
*/
|
||||
mid_file_count = 0;
|
||||
|
||||
while(wait_count < 2){
|
||||
@@ -107,12 +102,10 @@ void *thread_mid(void *data){
|
||||
mid_content[selected_file_last].status &= ~FILE_STATUS_HOVER;
|
||||
}
|
||||
selected_file_last = selected_file_current;
|
||||
free(file_current);
|
||||
file_current = malloc(sizeof(file));
|
||||
free(file_current->file_name);
|
||||
|
||||
file_current->file_name_width = mid_content[selected_file_current].file_name_width;
|
||||
file_current->file_name = malloc(file_current->file_name_width);
|
||||
memcpy(file_current->file_name, mid_content[selected_file_current].file_name, file_current->file_name_width);
|
||||
file_current->file_name = malloc(strlen(mid_content[selected_file_current].file_name));
|
||||
strcpy(file_current->file_name, mid_content[selected_file_current].file_name);
|
||||
file_current->file_size = mid_content[selected_file_current].file_size;
|
||||
file_current->file_type = mid_content[selected_file_current].file_type;
|
||||
file_current->color_pair = mid_content[selected_file_current].color_pair;
|
||||
@@ -141,7 +134,6 @@ void *thread_lft(void *data){
|
||||
char *path;
|
||||
if((path=getcwd(NULL, 0)) == NULL) {
|
||||
lft_content = malloc(sizeof(file));
|
||||
lft_content[0].file_name_width = sizeof("cannot open directory");
|
||||
lft_content[0].file_name = "cannot open directory";
|
||||
lft_file_count = 1;
|
||||
} else {
|
||||
@@ -150,10 +142,10 @@ void *thread_lft(void *data){
|
||||
path[0] = '/';
|
||||
|
||||
if (status & STATUS_RELOAD_DIRECTORY) {
|
||||
lft_file_count = get_dir_size(path);
|
||||
free(lft_content);
|
||||
lft_file_count = (unsigned long)get_dir_size(path);
|
||||
lft_content = malloc(lft_file_count * sizeof(file));
|
||||
memset(lft_content, ' ', lft_file_count * sizeof(file));
|
||||
memset(lft_content, '\0', lft_file_count * sizeof(file));
|
||||
get_dir_content(path, &lft_file_count, lft_content);
|
||||
}
|
||||
|
||||
@@ -177,17 +169,15 @@ void *thread_rgt(void *data){
|
||||
pthread_mutex_lock(&mutex_selection);
|
||||
free(rgt_content);
|
||||
rgt_content = malloc(sizeof(file));
|
||||
rgt_content->file_name = malloc(file_current->file_name_width + 1);
|
||||
memcpy(rgt_content->file_name, file_current->file_name, file_current->file_name_width);
|
||||
rgt_content->file_name[file_current->file_name_width] = '\0';
|
||||
rgt_content->file_name_width = file_current->file_name_width;
|
||||
rgt_content->file_name = malloc(strlen(file_current->file_name));
|
||||
strcpy(rgt_content->file_name, file_current->file_name);
|
||||
rgt_content->file_size = file_current->file_size;
|
||||
rgt_content->file_type = file_current->file_type;
|
||||
rgt_content->status = file_current->status;
|
||||
pthread_mutex_unlock(&mutex_selection);
|
||||
|
||||
if (rgt_content->file_type == FILE_TYPE_DIR || rgt_content->file_type == FILE_TYPE_SYMLINK) {
|
||||
char *path = malloc(rgt_content[0].file_name_width + 1);
|
||||
char *path = malloc(strlen(rgt_content[0].file_name) + 1);
|
||||
strcpy(path, rgt_content[0].file_name);
|
||||
free(rgt_content);
|
||||
rgt_file_count = get_dir_size(path);
|
||||
@@ -277,17 +267,19 @@ void threading_init(){
|
||||
memset(rgt_buffer, '\0', sizeof(char));
|
||||
memset(btm_buffer, '\0', sizeof(char));
|
||||
|
||||
mid_content->file_type = 0;
|
||||
mid_content->file_size = 0;
|
||||
mid_content->file_name = malloc(sizeof(char));
|
||||
mid_content->file_name[0] = '\0';
|
||||
|
||||
rgt_content->file_type = 0;
|
||||
rgt_content->file_size = 0;
|
||||
rgt_content->file_name_width = 0;
|
||||
rgt_content->file_name = malloc(sizeof(char));
|
||||
rgt_content->file_name[0] = '\0';
|
||||
|
||||
file_current = malloc(sizeof(file));
|
||||
file_current->file_type = 0;
|
||||
file_current->file_size = 0;
|
||||
file_current->file_name_width = 0;
|
||||
file_current->file_name = malloc(sizeof(char));
|
||||
file_current->file_name[0] = '\0';
|
||||
|
||||
|
Reference in New Issue
Block a user