I think the problem to which JPARADA is referring to, comes from the above denoted "return NULL" statement, that perhaps should be "return 0".
(but again, maybe i' m wrong since my C knowledge could easily be compared to my Spanish language fluency which is near (but not equal) to zero... )