History

Replace malloc+strcpy by tcc_strdup in ld_load_file_list

Thomas Preud'homme committed 16 years ago

Commit a64a6f31 parent 6525a151 file · +3 −9Browse files

Unified · Split

tccelf.c+3−9
@@ -2944,15 +2944,9 @@ static int ld_add_file_list(TCCState *s1, const char *cmd, int as_needed) · 2943 unmodified lines
29442944 if (ret)
29452945 goto lib_parse_error;
29462946 if (group) {
2947− char *file_name, *lib_name;
2948−
2949− /* Add the filename and the libname to avoid future conversions */
2950− file_name = tcc_malloc(sizeof(char) * (strlen(filename) + 1));
2951− strcpy(file_name, filename);
2952− dynarray_add((void ***) &libs, &nblibs, file_name);
2953− lib_name = tcc_malloc(sizeof(char) * (strlen(libname) + 1));
2954− strcpy(lib_name, libname);
2955− dynarray_add((void ***) &libs, &nblibs, lib_name);
2947+ /* Add the filename *and* the libname to avoid future conversions */
2948+ dynarray_add((void ***) &libs, &nblibs, tcc_strdup(filename));
2949+ dynarray_add((void ***) &libs, &nblibs, tcc_strdup(libname));
29562950 }
29572951 }
29582952 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t