view finch/libgnt/pygnt/common.c @ 21520:f3e3c604ea0e

merge of '61d876a57f30f4e29a91a8411d259e8aaa4355ea' and '8f4c83ded385e01c8c6b04edd91d02dac0c09571'
author Will Thompson <will.thompson@collabora.co.uk>
date Thu, 15 Nov 2007 12:55:17 +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;
}