This is hilarious. SIZE_MAX is at least as large as the largest string that you can put in your address space / memory anyway. Which is what the strlen() API already assumes.
That, plus you'd be a fool to store a huge string in this way anywhere (in or out of memory) in any case.
> SIZE_MAX is at least as large as the largest string that you can put in your address space / memory anyway.
Not necessarily. A 64-bit system could give processes an address space that’s significantly larger than half the full 64-bit address space and have an allocator that allows you to allocate a block of more than SIZE_MAX bytes (malloc takes a size_t, but you can use calloc)
jstimpfle|3 years ago
That, plus you'd be a fool to store a huge string in this way anywhere (in or out of memory) in any case.
Someone|3 years ago
Not necessarily. A 64-bit system could give processes an address space that’s significantly larger than half the full 64-bit address space and have an allocator that allows you to allocate a block of more than SIZE_MAX bytes (malloc takes a size_t, but you can use calloc)
pjmlp|3 years ago
jcelerier|3 years ago