view finch/libgnt/pygnt/common.c @ 20191:0f964c98798c

applied changes from 8df1cedfbc540695a8645b21230d41783fe4f171 through 326d6e6c8c6a955cdba84f1f802fc21ec3e6b662
author Richard Laager <rlaager@wiktel.com>
date Fri, 28 Sep 2007 15:01:27 +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;
}