From 42251323b4d0a25b2b0a5697d6ee2cdc60427a12 Mon Sep 17 00:00:00 2001 From: Jack Jansen Date: Wed, 8 May 2002 22:13:51 +0000 Subject: [PATCH] Fixed string and dict conversion, and implemented booleans and numbers (int and float). I think we now have enough CFType support to start on plists and CFpreferences! Transparent handling of unknown CFType objects still TBD. --- Mac/Modules/cf/pycfbridge.c | 63 ++++++++++++++++++++++++++++--------- 1 file changed, 49 insertions(+), 14 deletions(-) diff --git a/Mac/Modules/cf/pycfbridge.c b/Mac/Modules/cf/pycfbridge.c index a44c404120..1b7d7c5950 100644 --- a/Mac/Modules/cf/pycfbridge.c +++ b/Mac/Modules/cf/pycfbridge.c @@ -4,6 +4,7 @@ #ifdef WITHOUT_FRAMEWORKS #include +#include #include #include #include @@ -66,25 +67,30 @@ err: PyObject * PyCF_CF2Python_mapping(CFTypeRef src) { int size = CFDictionaryGetCount(src); - PyObject *rv; - CFTypeRef *allkeys, *allvalues; + PyObject *rv = NULL; + CFTypeRef *allkeys = NULL, *allvalues = NULL; CFTypeRef key_cf, value_cf; PyObject *key_py = NULL, *value_py = NULL; int i; allkeys = malloc(size*sizeof(CFTypeRef *)); - if (allkeys == NULL) return PyErr_NoMemory(); + if (allkeys == NULL) { + PyErr_NoMemory(); + goto err; + } allvalues = malloc(size*sizeof(CFTypeRef *)); - if (allvalues == NULL) return PyErr_NoMemory(); - if ( (rv=PyDict_New()) == NULL ) - return NULL; + if (allvalues == NULL) { + PyErr_NoMemory(); + goto err; + } + if ( (rv=PyDict_New()) == NULL ) goto err; CFDictionaryGetKeysAndValues(src, allkeys, allvalues); for(i=0; iob_type->tp_name); -- 2.40.0