When I tried this sample code, it failed due to a NULL namespace being returned (and a later strdup(NULL)).