previous | start | next

Pointer Types

In the find_fit function the pointer bp pointed to the allocated/free part of a block.

The type of bp was:

        void *bp;
     

The malloc function is used to allocate heap memory no matter what type will be stored in that memory. So we can't tell the C compiler exactly what type (or size) it will point to.

One way to deal with this is to declare it as a void pointer.

Sometimes will want to treat it as a pointer to a single byte:

        char *p;
     

But to get the header information, we will need a pointer to an int (e.g. size_t):

        size_t *p;
     


previous | start | next