在mplab pic32 linker标签下已经设定好堆的大小,程序如下。软件仿真发现p1,p2均为NULL
void main(void)
{
unsigned char *p1;
unsigned char *p2;
p1 = (unsigned char *)malloc(2);
if (p1 != NULL)
{
p1[0] = '0';
}
else
{
}
p2 = (unsigned char *)malloc(3);
if (p2 != NULL)
{
p2[0] = '0';
}
else
{
}
while (1)
{
}
} |