title: Creating a struct at address pointed by pointer
body: <p>I have a <code>unsigned char* head</code> that is pointing to a certain addess in memory and now I have to create a typedef struct that I've declared starting at the location of that pointer...I am confused on how to do that!</p>
  
  <p>Here is the declaration of the typedef</p>
  
  <pre><code> typedef struct {
      struct block *next;
      struct block *prev;
      int size;
      unsigned char *buffer;
  } block;
  </code></pre>
  
  <p>My assignment involves implementing malloc, so I can't use malloc. A block is part of a free_list which contains all chunks of free memory blocks that I have in my program heap. Hence, the previous and next pointers that point to the previous and next free blocks of memory.</p>
  
  <p>Head points to the start of the free_list. When I have to split say the first block of free memory to satisfy a malloc() request that needs less space then that free block has I need to move my head and create a new block struct there.</p>
  
  <p>Hope this makes sense. If not, the assignment looks something like <a href="http://www.cs.ucsb.edu/~rich/class/cs170/labs/lab1.malloc/" rel="nofollow">this</a></p>