The only C function that allocates memory is malloc() and it is dependent upon the underlying operating system.
If you are working on an OS kernel you need to write a complete memory manager, that is, the underlying stuff behind malloc()...
Usually memory is allocated by placing frames around blocks of memory... they form a sort of linked list (loose analogy, but close enough for illustration purposes) of allocated blocks, each pointing to the next. You start at the bottom (or top) of memory and allocate 100 bytes, so you put a frame there, the frame contains a pointer to the next block and the size of the current block and you return a pointer to the first byte of the block to the program... to allocate another block you simply add a nother frame...
Code:
*
*allocated block
*
size of this block
pointer to next block
===================
*
* allocated block
*
Size of this block
pointer to next block
====================
Then to deallocate a block you fix the pointers and remove the frame...
You know where each block begins and ends, so as you add and remove blocks you can "manage" the memory by filling gaps.
Of course it's a little bit more complicated than this --well, more than a little actually-- but that's the jist of it... If you understand linked lists you understand memory management.