Well, I believe the answer/problem is in these few lines:
SDL_Surface* thing;
SDL_LockSurface(thing);
put_pixel32(thing,2,2,SDLred);
SDL_UnlockSurface(thing);
apply_surface(0,0,thing,screen);
SDL_Flip(screen);
The locking/unlocking dosn't seem to do much, if I delete the lines the same thing happens, and if I check if it must lock before, the program still returns 3, etc.