【发布时间】:2015-12-16 09:51:17
【问题描述】:
我正在尝试检查指针数组中的指针是否为 NULL。运行时程序崩溃,调试器指向if() 条件但我不知道它出了什么问题。
在main.c
unsigned int** memory = malloc(sizeof(unsigned int*)*MEMORY_SIZE);
/* malloc failed */
if (!memory)
{
return EXIT_FAILURE;
}
Process myProcess = { 1, 2, -1};
/* TEST THAT WORKS */
/* memory[0] = &(myProcess.m_id); */
/* printf("%u", *memory[0]); */
AllocFirstFit(&myProcess, memory);
在另一个.c 文件中
void AllocFirstFit(Process* process, unsigned int** memory)
{
unsigned int itr_mry;
/* Declaration of various other local variable here*/
/* browsing the memory */
for(itr_mry = 0; itr_mry < MEMORY_SIZE; ++itr_mry)
{
/* if memory unit is null */
/* debugger point this line. This condition is never true for some reason */
if(memory[itr_mry] == NULL)
{
【问题讨论】: