RFR-8008118
Mark Sheppard
mark.sheppard at oracle.com
Tue Apr 2 22:20:56 UTC 2013
Hi Martin,
are there any concerns that the string literal "." might be on the
stack and not in data segment or heap?
In previous exchanges the static const char *const cwd was declared to
put it in read only memory.
Also, is it assured that the returned parentPathv will never be
de-allocated? I don't see parentPathv exposed beyond //
that of UNIXProcess_md.c, at least not directly.
regards
Mark
On 28/03/2013 19:10, christos at zoulas.com wrote:
> On Mar 28, 11:12am, martinrb at google.com (Martin Buchholz) wrote:
> -- Subject: Re: RFR-8008118
>
> | My apologies for unrelenting perfectionism - I noticed that we can:
> | - colocate the pathv and path in one malloc'ed chunk
> | - can discard xstrdup
> | - can iterate through path with only one char* pointer.
> |
> | Making this code even cleaner, more concise and efficient.
>
>
> - for (i = 0; i < count; i++, p++) {
> - pathv[i] = ((*p == ':') || (*p == '\0')) ? "." : p;
> - while (! ((*p == ':') || (*p == '\0')))
> - p++;
> - *p = '\0';
> - }
> - pathv[count] = NULL;
>
> + for (i = 0; (pathv[i] = strsep(&p, ":")) != NULL; i++)
> + if (!pathv[i][0])
> + pathv[i] = ".";
>
> christos
More information about the core-libs-dev
mailing list