I want to create a small list of Entites. For this I want to connect each pointer with its neighbours (prev, next), a simple linked list... The problem is that I cant change the given first/last pointer so it becomes valid outside the function scope:

#include <acknex.h>
#include <default.c>

ENTITY* pEmeter_first;
ENTITY* pEmeter_last;

#define ent_nextListObj skill97

//Add an object to the list
void ent_listAdd(ENTITY* p, ENTITY** first, ENTITY** last)
{
if (first == NULL) {
&first = &p;
&last = &p;
return;
}

last.ent_nextListObj = &p;
last = &p;
}

void main()
{
level_load(NULL);

wait(2);

pEmeter_first = NULL;
pEmeter_last = NULL;

ENTITY* p = ent_create(CUBE_MDL,nullvector,NULL);

ent_listAdd(p, &pEmeter_first, &pEmeter_last);

if (p == pEmeter_first) {
error("JUP!");
} else {
if (pEmeter_first == NULL) {
error("URGHS!");
} else {
error("???");
}
}
}


I want to see a "JUP" on my screen, so maybe you can help me? laugh

I've also uploaded the testfile here:
http://user.crew51.com/weinhold/main.c