title: What is the limit on malloc parameter of type size_t in C? Docs say it has an upper limit of UINT_MAX but I can't go beyond INT_MAX
body: <p>I want to allocate a 2.9GB char array with </p>
  
  <pre><code>  database = (char*) malloc((2900 * 1000000 * sizeof(char)));
  </code></pre>
  
  <p>This gives an integer overflow warning and the <code>malloc</code> returns <code>NULL</code>. The
  <code>malloc</code> parameter is of type <code>size_t</code> which according to documentation is of type 
  <code>unsigned int</code>. </p>
  
  <p>So the max should be <code>UINT_MAX</code> which is at least 2.9GB. However, if
  I try to allocate more than <code>MAX_INT</code> the <code>malloc</code> fails. Does this mean 
  <code>size_t</code> on my system is of type int? How do I check this? I looked through </p>
  
  <pre><code>/usr/include/stdlib.h 
  </code></pre>
  
  <p>and </p>
  
  <pre><code>./lib/gcc/x86_64-redhat-linux/4.1.1/include/stddef.h 
  </code></pre>
  
  <p>but
  can't find the definition of <code>size_t</code>. Thanks very much</p>