mirror of
https://gittea.dev/nova/th.git
synced 2025-10-25 12:20:16 -04:00
removal of all strcpy
This commit is contained in:
@@ -24,7 +24,7 @@ char* smartstrcasestr(char *haystack, const char *needle){
|
|||||||
needle -= passes;
|
needle -= passes;
|
||||||
if (smart == 0) {
|
if (smart == 0) {
|
||||||
char *needle_case = malloc(strlen(needle)+1);
|
char *needle_case = malloc(strlen(needle)+1);
|
||||||
strcpy(needle_case, needle);
|
memcpy(needle_case, needle, strlen(needle));
|
||||||
passes = 0;
|
passes = 0;
|
||||||
while (*needle_case) {
|
while (*needle_case) {
|
||||||
*needle_case = *needle_case | ' ';
|
*needle_case = *needle_case | ' ';
|
||||||
@@ -34,7 +34,7 @@ char* smartstrcasestr(char *haystack, const char *needle){
|
|||||||
needle_case -= passes;
|
needle_case -= passes;
|
||||||
|
|
||||||
char *haystack_case = malloc(strlen(haystack)+1);
|
char *haystack_case = malloc(strlen(haystack)+1);
|
||||||
strcpy(haystack_case, haystack);
|
memcpy(haystack_case, haystack, strlen(haystack));
|
||||||
passes = 0;
|
passes = 0;
|
||||||
while (*haystack_case) {
|
while (*haystack_case) {
|
||||||
*haystack_case = *haystack_case | ' ';
|
*haystack_case = *haystack_case | ' ';
|
||||||
|
|||||||
2
colors.c
2
colors.c
@@ -108,7 +108,7 @@ void colors_init() {
|
|||||||
if (line[0] == '.') {
|
if (line[0] == '.') {
|
||||||
extension = strtok(line, " ");
|
extension = strtok(line, " ");
|
||||||
colors[i].file_extension = malloc(strlen(extension)+1);
|
colors[i].file_extension = malloc(strlen(extension)+1);
|
||||||
strcpy(colors[i].file_extension, extension);
|
memcpy(colors[i].file_extension, extension, strlen(extension)+1);
|
||||||
|
|
||||||
colors[i].color_pair = i+11;
|
colors[i].color_pair = i+11;
|
||||||
parse_colors(line, &fg, &bg);
|
parse_colors(line, &fg, &bg);
|
||||||
|
|||||||
2
dir.c
2
dir.c
@@ -66,7 +66,7 @@ void get_dir_content(char *path, unsigned long *dir_file_count, file *dir_conten
|
|||||||
if (entry[i]->d_name[0] == '.' && !(file_modifiers & FILE_MODIFIERS_HIDDEN_FILES)) {
|
if (entry[i]->d_name[0] == '.' && !(file_modifiers & FILE_MODIFIERS_HIDDEN_FILES)) {
|
||||||
} else {
|
} else {
|
||||||
dir_content[i].file_name = malloc(strlen(entry[i]->d_name)+1);
|
dir_content[i].file_name = malloc(strlen(entry[i]->d_name)+1);
|
||||||
strcpy(dir_content[i].file_name, entry[i]->d_name);
|
memcpy(dir_content[i].file_name, entry[i]->d_name, strlen(entry[i]->d_name) + 1);
|
||||||
|
|
||||||
|
|
||||||
struct stat *file;
|
struct stat *file;
|
||||||
|
|||||||
@@ -274,7 +274,7 @@ void move_right(){
|
|||||||
cmd = concat(cmd, "\"");
|
cmd = concat(cmd, "\"");
|
||||||
btm_buffer = malloc(strlen(cmd));
|
btm_buffer = malloc(strlen(cmd));
|
||||||
|
|
||||||
strcpy(btm_buffer, cmd-1);
|
memcpy(btm_buffer, cmd, strlen(cmd));
|
||||||
|
|
||||||
|
|
||||||
if (system(cmd) == -1) {
|
if (system(cmd) == -1) {
|
||||||
@@ -590,7 +590,7 @@ void jump_to_dir(unsigned long passes, int index){
|
|||||||
ch = (char*)key_binding[index].black_magic;
|
ch = (char*)key_binding[index].black_magic;
|
||||||
if (*ch == '/') {
|
if (*ch == '/') {
|
||||||
path = malloc(strlen((char*)key_binding[index].black_magic));
|
path = malloc(strlen((char*)key_binding[index].black_magic));
|
||||||
strcpy(path, (char*)key_binding[index].black_magic);
|
memcpy(path, (char*)key_binding[index].black_magic, strlen((char*)key_binding[index].black_magic)+1);
|
||||||
} else if (slash) {
|
} else if (slash) {
|
||||||
env_str = malloc(env_len * sizeof(char));
|
env_str = malloc(env_len * sizeof(char));
|
||||||
memcpy(env_str, (char*)key_binding[index].black_magic +1, env_len);
|
memcpy(env_str, (char*)key_binding[index].black_magic +1, env_len);
|
||||||
@@ -600,16 +600,16 @@ void jump_to_dir(unsigned long passes, int index){
|
|||||||
path = concat(env_parsed, (char*)key_binding[index].black_magic + env_len);
|
path = concat(env_parsed, (char*)key_binding[index].black_magic + env_len);
|
||||||
} else {
|
} else {
|
||||||
path = malloc(strlen((char*)key_binding[index].black_magic));
|
path = malloc(strlen((char*)key_binding[index].black_magic));
|
||||||
strcpy(path, (char*)key_binding[index].black_magic);
|
memcpy(path, (char*)key_binding[index].black_magic, strlen((char*)key_binding[index].black_magic)+1);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
env_parsed = getenv((char*)key_binding[index].black_magic +1);
|
env_parsed = getenv((char*)key_binding[index].black_magic +1);
|
||||||
if (env_parsed) {
|
if (env_parsed) {
|
||||||
path = malloc(strlen(env_parsed)+1);
|
path = malloc(strlen(env_parsed)+1);
|
||||||
strcpy(path, env_parsed);
|
memcpy(path, env_parsed, strlen(env_parsed)+1);
|
||||||
} else {
|
} else {
|
||||||
path = malloc(strlen((char*)key_binding[index].black_magic));
|
path = malloc(strlen((char*)key_binding[index].black_magic));
|
||||||
strcpy(path, (char*)key_binding[index].black_magic);
|
memcpy(path, (char*)key_binding[index].black_magic, strlen((char*)key_binding[index].black_magic)+1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (chdir(path) != 0) {
|
if (chdir(path) != 0) {
|
||||||
@@ -772,13 +772,13 @@ void yank_file(unsigned long passes, int index){
|
|||||||
yank_files.count = 1;
|
yank_files.count = 1;
|
||||||
yank_files.list = (char**)malloc(yank_files.count * sizeof(char*));
|
yank_files.list = (char**)malloc(yank_files.count * sizeof(char*));
|
||||||
*yank_files.list = malloc(strlen(mid_content[selected_file_current].file_name)+1);
|
*yank_files.list = malloc(strlen(mid_content[selected_file_current].file_name)+1);
|
||||||
strcpy(*yank_files.list, mid_content[selected_file_current].file_name);
|
memcpy(*yank_files.list, mid_content[selected_file_current].file_name, strlen(mid_content[selected_file_current].file_name));
|
||||||
} else {
|
} else {
|
||||||
yank_files.list = malloc(yank_files.count * sizeof(char*));
|
yank_files.list = malloc(yank_files.count * sizeof(char*));
|
||||||
for (i = 0; i < mid_file_count; i++) {
|
for (i = 0; i < mid_file_count; i++) {
|
||||||
if (mid_content[i].status & FILE_STATUS_SELECTED) {
|
if (mid_content[i].status & FILE_STATUS_SELECTED) {
|
||||||
*yank_files.list = malloc(strlen(mid_content[i].file_name)+1);
|
*yank_files.list = malloc(strlen(mid_content[i].file_name)+1);
|
||||||
strcpy(*yank_files.list, mid_content[i].file_name);
|
memcpy(*yank_files.list, mid_content[i].file_name, strlen(mid_content[i].file_name));
|
||||||
yank_files.list += 1;
|
yank_files.list += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -150,7 +150,7 @@ void *thread_rgt(){
|
|||||||
char *path;
|
char *path;
|
||||||
if (mid_file_count != 0) {
|
if (mid_file_count != 0) {
|
||||||
path = malloc(strlen(mid_content[selected_file_current].file_name) + 1);
|
path = malloc(strlen(mid_content[selected_file_current].file_name) + 1);
|
||||||
strcpy(path, mid_content[selected_file_current].file_name);
|
memcpy(path, mid_content[selected_file_current].file_name, strlen(mid_content[selected_file_current].file_name)+1);
|
||||||
} else {
|
} else {
|
||||||
path = malloc(sizeof(char));
|
path = malloc(sizeof(char));
|
||||||
path[0] = '\0';
|
path[0] = '\0';
|
||||||
|
|||||||
Reference in New Issue
Block a user