I'm trying to check if a pointer is NULL in an array of pointer. Program crash when running, debbugger point to the if() condition but I don't know what it wrong.
In 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);
In another .c file
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)
{