+ void *p;
+
+ state = p = realloc(old, offsetof(struct err_state, str) + buf_size);
+ if (state) {
+ state->nstr = buf_size;
+ } else if (old) {
+ /* Failed allocation, but existing state is still good */
+ p = old;
+ } else {
+ /* Failed allocation, no existing state */
+ p = &err_no_mem;
+ }
+
+ gl_tls_set(tls_key, p);
+ return state;
+}
+
+static struct err_state *get_err_state(void)
+{
+ void *state;