appid is a pointer, not a int value, I believe. Therefore, testing for > 0 is totally wrong. It might as well be < 0. The only correct test would be against zero.