+/* {Keys}
+ */
+
+static int n_keys = 0;
+static int max_keys = 0;
+static void (**destructors) (void *) = 0;
+
+int
+coop_key_create (coop_k *keyp, void (*destructor) (void *value))
+{
+ if (n_keys >= max_keys)
+ {
+ int i;
+ max_keys = max_keys ? max_keys * 3 / 2 : 10;
+ destructors = realloc (destructors, sizeof (void *) * max_keys);
+ if (destructors == 0)
+ {
+ fprintf (stderr, "Virtual memory exceeded in coop_key_create\n");
+ exit (1);
+ }
+ for (i = n_keys; i < max_keys; ++i)
+ destructors[i] = NULL;
+ }
+ destructors[n_keys] = destructor;
+ *keyp = n_keys++;
+ return 0;
+}
+
+int
+coop_setspecific (coop_k key, const void *value)
+{
+ int n_keys = coop_global_curr->n_keys;
+ if (key >= n_keys)
+ {
+ int i;
+ coop_global_curr->n_keys = max_keys;
+ coop_global_curr->specific = realloc (n_keys
+ ? coop_global_curr->specific
+ : NULL,
+ sizeof (void *) * max_keys);
+ if (coop_global_curr->specific == 0)
+ {
+ fprintf (stderr, "Virtual memory exceeded in coop_setspecific\n");
+ exit (1);
+ }
+ for (i = n_keys; i < max_keys; ++i)
+ coop_global_curr->specific[i] = NULL;
+ }
+ coop_global_curr->specific[key] = (void *) value;
+ return 0;
+}
+
+void *
+coop_getspecific (coop_k key)
+{
+ return (key < coop_global_curr->n_keys
+ ? coop_global_curr->specific[key]
+ : NULL);
+}
+
+int
+coop_key_delete (coop_k key)
+{
+ return 0;
+}
+