view finch/libgnt/pygnt/common.c @ 20700:4b91ac9fa549

propagate from branch 'im.pidgin.pidgin.2.2.1' (head e7d234a12dbb89fdfd195e4597018a80f2c541f5) to branch 'im.pidgin.pidgin' (head a695ddc8921e9705ecd1e680473d692e73449845)
author Daniel Atallah <daniel.atallah@gmail.com>
date Fri, 28 Sep 2007 21:49:48 +0000
parents 5e1412f4e67a
children
line wrap: on
line source

#include "common.h"

PyObject *
create_pyobject_from_string_list(GList *list)
{
	PyObject *py_list;
	if (list == NULL) {
		Py_INCREF(Py_None);
		return Py_None;
	}
	if ((py_list = PyList_New(0)) == NULL) {
		g_list_foreach(list, (GFunc)g_free, NULL);
		g_list_free(list);
		return NULL;
	}
	while (list) {
		PyObject *obj = PyString_FromString(list->data);
		PyList_Append(py_list, obj);
		Py_DECREF(obj);
		g_free(list->data);
		list = g_list_delete_link(list, list);
	}
	return py_list;
}