mirror of
https://github.com/gnustep/tools-make.git
synced 2025-04-22 22:00:49 +00:00
Modified for systems where realloc() doesn't cope with nul pointers.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/tools/make/trunk@2599 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
4d4e8eafce
commit
ee8e30f158
1 changed files with 8 additions and 2 deletions
10
which_lib.c
10
which_lib.c
|
@ -137,14 +137,20 @@ void get_arguments (int argc, char** argv)
|
|||
|
||||
for (i = 0; i < argc; i++) {
|
||||
if (!strncmp (argv[i], "-l", 2)) {
|
||||
all_libraries = realloc (all_libraries,
|
||||
if (all_libraries)
|
||||
all_libraries = realloc (all_libraries,
|
||||
(libraries_no + 1) * sizeof (char*));
|
||||
else
|
||||
all_libraries = malloc ((libraries_no + 1) * sizeof (char*));
|
||||
all_libraries[libraries_no] = malloc (strlen (argv[i]) - 1);
|
||||
strcpy (all_libraries[libraries_no], argv[i] + 2);
|
||||
libraries_no++;
|
||||
}
|
||||
else if (!strncmp (argv[i], "-L", 2)) {
|
||||
library_paths = realloc (library_paths, (paths_no + 1) * sizeof (char*));
|
||||
if (library_paths)
|
||||
library_paths = realloc (library_paths, (paths_no + 1) * sizeof(char*));
|
||||
else
|
||||
library_paths = malloc ((paths_no + 1) * sizeof(char*));
|
||||
library_paths[paths_no] = malloc (strlen (argv[i]) - 1);
|
||||
strcpy (library_paths[paths_no], argv[i] + 2);
|
||||
paths_no++;
|
||||
|
|
Loading…
Reference in a new issue