The problem could be a number of things. Try testing your user-defined function in a stand-alone test program first.
You are pfree'ing something that was not palloc'ed. Beware of mixing malloc/free and palloc/pfree.
Send your extensions to the pgsql-hackers mailing list, and they will eventually end up in the contrib/ subdirectory.
This requires wizardry so extreme that the authors have never tried it, though in principle it can be done.
The Makefiles do not have the proper dependencies for include files. You have to do a make clean and then another make.