Dumb luck... Really... just plain old fashioned dumb luck.

In your getconf function you are making two crucial mistakes...
1) you are creating a pointer ... char *value... that points to...