请问关于构造alloc函数的相关有关问题

请教关于构造alloc函数的相关问题
用C语言指针编写一个函数alloc(n) ,用来在内存区开辟一个连续的空间(n个字节)。此函数的返回值是一个指针, 只想新开辟的连续空间的起始地址。 再写一个函数free(p),将起始地址p开始的各单元释放(不能再被程序使用 ,除非再度开辟)。
#include <stdio.h>
#define LEN (1000) 
unsigned char base[LEN];
unsigned char *p=(unsigned char *)base;
unsigned char *Alloc(unsigned int n)
{
    unsigned char *pp=p;
    if(p+sizeof(unsigned int)+n<base+LEN&&n>0)
    {
        *(unsigned int*)p=n;
        p+=sizeof(unsigned int)+n;
        pp+=sizeof(unsigned int);
    }
    else
    {
        pp=NULL;
    }
    return pp;
}

void Free(unsigned char *ptr)
{
    if(!ptr)
        return;
    p-=sizeof(unsigned int)+*(unsigned int *)(ptr-sizeof(unsigned int));
}

int main()
{
    unsigned char *a=NULL;
    printf("base=%p,p=%p,a=%p\n",base,p,a);
    a=Alloc(10);
    printf("base=%p,p=%p,a=%p\n",base,p,a);
    Free(a);
    printf("base=%p,p=%p,a=%p\n",base,p,a);
    return 0;
}

请教一下alloc函数和free函数里面的功能是怎么实现的,有点看不懂
------解决方案--------------------
首先,定义了一个长为LEN的base数组,所有分配的内存都是在这个数组上面的。
然后 将p指向未分配的内存首地址,第一次分配时,首地址就是base.
alloc分配开始,参数n指明了要分配多少字节。
于是在首地址分配4字节(即sizeof(unsigned int)的长度)表存放n的值班,然后将p赋值给pp,然后将p移到n+sizeof(unsigned int)的地方。这样p还是表示空闲的内存空间。
返回pp.

free,就是找到pp所在的位置,因为我们知道有一个n存在pp这个位置,这个n表示后面的n个内存都可以释放掉,于是将p向前移动n个字节。