diff options
Diffstat (limited to 'src/stringlist.c')
-rw-r--r-- | src/stringlist.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/stringlist.c b/src/stringlist.c index ad1acf3..8f37dac 100644 --- a/src/stringlist.c +++ b/src/stringlist.c @@ -28,7 +28,7 @@ int stringListInsertAt(StringList *l, unsigned int pos, char *str) if(!l || !l->list || l->count < pos) return 0; - l->list[pos] = str; + l->list[pos] = strdup(str); return 1; } @@ -77,7 +77,7 @@ StringList* listToCList(PyObject* list) if (PyUnicode_Check(elem)) { PyObject *tmp = PyUnicode_AsUTF8String(elem); - val = strdup(PyString_AsString(tmp)); + val = PyString_AsString(tmp); Py_DECREF(tmp); } else if (PyString_Check(elem)) @@ -125,6 +125,17 @@ void stringListPrint(StringList* list) } } +int stringListContains(StringList* list, char* str) +{ + for(unsigned int i = 0; i < list->count; i++) + { + if (0 == strcmp(list->list[i], str)) + return 1; + } + + return 0; +} + /* * Frees a string list and it's data */ |