static void _atomset_remove(struct set *ss, unsigned int key) { void **p = _findkey(ss, key, 0); if (p != NULL && *p != NULL) { PYDECREF((PyObject*) *p); ss->population--; *p = NULL; } }
static PyObject *atomset_get(struct set *ss, unsigned int key) { void **p = _findkey(ss, key, 0); if (p == NULL || *p == NULL) { Py_INCREF(Py_None); return Py_None; } PyObject *po = (PyObject *) *p; Py_INCREF(po); return po; }
static int _atomset_set(struct set *ss, unsigned int key, PyObject *obj) { void **p = _findkey(ss, key, 1); if (p != NULL) { if (*p != NULL) { PYDECREF((PyObject *) *p); ss->population--; } Py_INCREF(obj); *((PyObject**) p) = obj; ss->population++; return 0; } return 1; }
static int _atomset_contains(struct set *ss, unsigned int key) { void **p = _findkey(ss, key, 0); return p != NULL && *p != NULL; }
void test(const char *s){ int kl = _findkey(s, strlen(s)); printf("%s\t%d\n", s, kl); }