Raymond Toy pushed to branch issue-306-lisp.c at cmucl / cmucl
Commits: 85f8ed4e by Raymond Toy at 2024-07-25T06:49:51-07:00 Don't need to do strdup when setting cmucllib in main()
As noted by @cshapiro, `cmucllib` isn't modified so in the couple of places we don't need to use strdup because:
* `cmucllib` isn't modified anywhere * the variables where strdup was called are never changed either so `cmucllib` wouldn't get modified in weird ways either.
Static analyzer doesn't complain, and we get to remove a couple of calls to `check_ptr`.
- - - - -
1 changed file:
- src/lisp/lisp.c
Changes:
===================================== src/lisp/lisp.c ===================================== @@ -758,15 +758,13 @@ main(int argc, const char *argv[], const char *envp[]) * neither are set, set cmucllib to our default search path. */ if (lib != NULL) { - cmucllib = strdup(lib); - check_ptr(cmucllib, "No space for strdup(lib)"); + cmucllib = lib; } else { char *libvar;
libvar = getenv("CMUCLLIB"); if (libvar != NULL) { - cmucllib = strdup(libvar); - check_ptr(cmucllib, "No space for strdup(libvar)"); + cmucllib = libvar; } else { /* * The following doesn't make sense for executables. They
View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/commit/85f8ed4ee05fe087907bfc38...