title: Dynamically Allocate Memory without Malloc
body: <p>I've been given a task to dynamically manage memory to beat the speed of malloc. Some requirements:</p>
  
  <p>1) Have a pointer to a struct </p>
  
  <p>2) Use "Chunks" of memory</p>
  
  <p>3) The memory will be allocated with a call like</p>
  
  <pre><code>init(memory * mem, int chunk_size, int num_chunks)
  </code></pre>
  
  <p>4) The memory pointer will be declared globally.</p>
  
  <p>5) Not using system calls</p>
  
  <p>So, I've thought about having my struct simply just:</p>
  
  <pre><code>typdef struct {
    char *byte;
  } memory;
  </code></pre>
  
  <p>And then that would leave my init function to do something like:</p>
  
  <pre><code>mem = new memory[chunk_size * num_chunks];
  </code></pre>
  
  <p>I don't know if you can do that in C -- normally I would use malloc! And then to free would I be able to just be able to set the pointer to null? </p>
  
  <p>Thanks for the help!</p>