Частично исправил задачу №13

pull/4/head
Igor Belitskiy 2 years ago
parent 9ec912d553
commit f98ad8b431

@ -1,4 +1,5 @@
#include "ubl-settings-resourcequota.h"
#include "ubl-utils.h"
config main_config;
main_window *widgets;
@ -611,7 +612,6 @@ void tree_view_add(int index) {
main_config.i_o_limit_write = yon_remalloc(main_config.i_o_limit_write, (main_config.size_tree_view + 1) * sizeof(int*));
main_config.i_o_limit_write_size = yon_remalloc(main_config.i_o_limit_write_size, (main_config.size_tree_view + 1) * sizeof(int*));
main_config.disk = yon_remalloc(main_config.disk, (main_config.size_tree_view + 1) * sizeof(char**));
philos_array_int_copy(&main_config.i_o_limit_write[main_config.size_tree_view], add_get_write_device());
philos_array_int_copy(&main_config.i_o_limit_write_size[main_config.size_tree_view], add_get_write_device_size_pow());
@ -670,9 +670,16 @@ char* format_io_limit_in_tree_view(config_str* disk, int** i_o_limit, int** i_o_
if (!strstr(str, "-")) {
char* num_and_pow_size = philos_format_cfg_str_size_memory(" ", i_o_limit[index][index_to_n2] , i_o_limit_size[index][index_to_n2]);
if (!strstr(num_and_pow_size, "-")) {
str = yon_char_unite(str, ",",
disk[index][index_to_n2], " ",
num_and_pow_size, NULL);
if (strlen(str)>3) {
str = yon_char_unite(str, ",",
disk[index][index_to_n2],
num_and_pow_size, NULL);
}
else {
str = yon_char_unite(disk[index][index_to_n2],
num_and_pow_size, NULL);
}
}
free(num_and_pow_size);
}
@ -683,7 +690,7 @@ char* format_io_limit_in_tree_view(config_str* disk, int** i_o_limit, int** i_o_
char* num_and_pow_size = philos_format_cfg_str_size_memory(" ", i_o_limit[index][index_to_n2], i_o_limit_size[index][index_to_n2]);
if (!strstr(num_and_pow_size, "-")) {
str = yon_char_unite(str,
disk[index][index_to_n2], " ",
disk[index][index_to_n2],
num_and_pow_size, NULL);
}
free(num_and_pow_size);
@ -1043,25 +1050,15 @@ char* add_io_str_format_ubconfig(char* key, int** i_o_limit, int** i_o_limit_s
if (i_o_limit_size[index] == NULL) {return NULL;}
if (i_o_limit[index] == NULL) {return NULL;}
int len_array = 0;
for (int i = 0;i_o_limit[index][i] != -2; i++) {
len_array += 1;
}
for (int i=0; i<len_array; i++) {
int read_limit = i_o_limit[index][i];
char* read_disk = disk[index][i];
int read_limit_size = i_o_limit_size[index][i];
if (read_limit >= 0 && read_disk && read_limit_size >= 0) {
if (i==0 && strlen(cmd_io) < 3) {
cmd_io = yon_char_unite(cmd_io, key, "=", NULL);
}
char* num_and_pow_size = philos_format_cfg_str_size_memory("",read_limit, read_limit_size);
cmd_io = yon_char_unite(cmd_io, split_simvol, read_disk, " ",num_and_pow_size, NULL);
split_simvol[0] = ',';
split_simvol[1] = '\0';
free(num_and_pow_size);
}
cmd_io = format_io_limit_in_tree_view(disk, i_o_limit, i_o_limit_size, index);
if (strlen(cmd_io) > 5) {
return yon_char_unite(key, "=", cmd_io, NULL);
}
else {
return yon_char_new("");
}
return cmd_io;
}

Loading…
Cancel
Save