Re: Array size limits

From: Ben Pfaff (blp_at_cs.stanford.edu)
Date: 08/31/04


Date: Mon, 30 Aug 2004 19:49:17 -0700

Carol Depore <nobody@nowhere.com> writes:

> How do I determine the maximum array size?

There is no portable way. You are better off using dynamic
allocation, because then you can try different sizes at runtime.

-- 
"Am I missing something?"
--Dan Pop


Relevant Pages

  • Re: [RFC PATCH] greatly reduce SLOB external fragmentation
    ... struct sizes will not change with compiler versions - that would ... allocation pattern differences, so timing will probably make a big ... There really is a reason why traditional heaps with first-fit are almost ...
    (Linux-Kernel)
  • Re: free()
    ... > Karl Malbrain wrote: ... >> You must accept that programs need to know the sizes of all of their ... > That is not possible, for most implementations of malloc, ... > time of allocation and the time of freeing. ...
    (comp.std.c)
  • Re: Code Review? memory management in C
    ... If you use Linux you might want to investigate valgrind, a very useful tool for checking for memory leaks amongst other things. ... Also, since this is a debugging aid, I would suggest testing size against INT_MAX from limits.h or some arbitrary lower value and reporting a problem if a ridiculously large allocation is made? ... BTW, although the earlier cast was not required, this one was. ... you might want to be clever and store the sizes somewhere and then look them up here rather than relying on passing in the correct old size. ...
    (comp.lang.c)
  • Re: free()
    ... > You must accept that programs need to know the sizes of all of their ... That is not possible, for most implementations of malloc, ... time of allocation and the time of freeing. ... not an appropriate use of the system library interface. ...
    (comp.std.c)
  • Re: [RFC PATCH] greatly reduce SLOB external fragmentation
    ... struct sizes will not change with compiler versions - that would ... allocation pattern differences, so timing will probably make a big ... There really is a reason why traditional heaps with first-fit are almost ...
    (Linux-Kernel)