CppParser: fix memory corruption issue

There are multiple places in the parser which do something similar to
this:

Foo *ptr = 0;

if (...) {
    Foo val = ...;
    ptr = &val;
}

func(ptr);

In other words, the code takes a pointer to a local variable, and the
pointer is used even after the local variable's scope has ended.

This causes a crash on Linux. For some reason this works fine on Windows
+ Visual studio.

This patchs moves the variable ("val" in the above example) to outer
scopes, so that its life time is extended to cover the use.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@iki.fi>
Merge pull request #261 from tomba/parser-mem-fix

CppParser: fix memory corruption issue