mirror of
https://github.com/opnsense/src.git
synced 2026-06-06 15:22:34 -04:00
kinfo_getfile: Add a comment explaining 4/3 ratio
We first get the expected size of the data from the kern.proc.filedesc sysctl, allocate 4/3 of that size, and then fetch the data. Add a comment about the reason (the fd table may grow between the two calls). Sponsored by: The FreeBSD Foundation
This commit is contained in:
parent
7c72c0822b
commit
4b60fac3a5
1 changed files with 4 additions and 0 deletions
|
|
@ -27,6 +27,10 @@ kinfo_getfile(pid_t pid, int *cntp)
|
|||
error = sysctl(mib, nitems(mib), NULL, &len, NULL, 0);
|
||||
if (error)
|
||||
return (NULL);
|
||||
/*
|
||||
* Add extra space as the table may grow between requesting the size
|
||||
* and fetching the data.
|
||||
*/
|
||||
len = len * 4 / 3;
|
||||
buf = malloc(len);
|
||||
if (buf == NULL)
|
||||
|
|
|
|||
Loading…
Reference in a new issue