hmm ... but StringMap probably expects string keys; so if key is a string, try xstrndup(key, key_size).