malloc, pointers and nested functions