Liste des Groupes | Revenir à cl c |
On 2024-03-11, Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote:Michael S <already5chosen@yahoo.com> writes:>
[...]Is there any chance at all that on typical Linux machine (i.e. the one>
configured to overcommit virtual memory) strdup() returns NULL?
If it was malloc() I'd say - no chance. For strdup() I'm less sure.
strdup() calls malloc(), so strdup() can return NULL if and only if
malloc() can return NULL -- but with the additional constraint that you
first need to have a string argument to strdup() that's long enough to
cause a suffiently large argument to be passed to malloc().
>
One data point: On my Ubuntu system, malloc(SIZE_MAX) returns NULL for
very large arguments (over about 23 GiB in my quick and dirty test).
I'm guessing that might be only be because of the overcommit_ratio
value; i.e that allowing a 23 GiB increment in the allocated address
space would bring the system over the currently configured overcommit
ratio.
Les messages affichés proviennent d'usenet.