Ok, now I think I got it all right. But I will have to go eat before I am thinking real clearly. Note that newlocale always has to do a new alloc and free the old later instead of realloc, so the name table can go from "short\0foo\0" to "longer\0foo\0" without clobbering "foo" before you get to it.