From 9ef0c7da71409115284b92764c4f748150745514 Mon Sep 17 00:00:00 2001 From: Benny Prijono Date: Wed, 14 Feb 2007 01:45:08 +0000 Subject: Fixed bug in Python module's normalize_stun_config(), and added Makefile for building Python module git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@944 74dad513-b988-da41-8d7b-12977e46ad98 --- pjsip-apps/src/py_pjsua/Makefile | 6 ++++++ pjsip-apps/src/py_pjsua/py_pjsua.c | 42 ++++++++++++++++++-------------------- 2 files changed, 26 insertions(+), 22 deletions(-) create mode 100644 pjsip-apps/src/py_pjsua/Makefile (limited to 'pjsip-apps/src/py_pjsua') diff --git a/pjsip-apps/src/py_pjsua/Makefile b/pjsip-apps/src/py_pjsua/Makefile new file mode 100644 index 00000000..10ed2fb3 --- /dev/null +++ b/pjsip-apps/src/py_pjsua/Makefile @@ -0,0 +1,6 @@ +all: + python setup.py install + +clean: + python setup.py clean + rm -rf ./build diff --git a/pjsip-apps/src/py_pjsua/py_pjsua.c b/pjsip-apps/src/py_pjsua/py_pjsua.c index cfa6adc4..cb370f1e 100644 --- a/pjsip-apps/src/py_pjsua/py_pjsua.c +++ b/pjsip-apps/src/py_pjsua/py_pjsua.c @@ -3130,38 +3130,36 @@ static PyObject *py_pjsua_normalize_stun_config { PyObject * tmpObj; stun_config_Object *obj; - pjsua_stun_config *cfg; + pjsua_stun_config cfg; if (!PyArg_ParseTuple(pArgs, "O", &tmpObj)) { return NULL; } - if (tmpObj != Py_None) - { - obj = (stun_config_Object *) tmpObj; - cfg = (pjsua_stun_config *)malloc(sizeof(pjsua_stun_config)); - cfg->stun_port1 = obj->stun_port1; - cfg->stun_port2 = obj->stun_port2; - cfg->stun_srv1.ptr = PyString_AsString(obj->stun_srv1); - cfg->stun_srv1.slen = strlen(PyString_AsString(obj->stun_srv1)); - cfg->stun_srv2.ptr = PyString_AsString(obj->stun_srv2); - cfg->stun_srv2.slen = strlen(PyString_AsString(obj->stun_srv2)); - } else { - cfg = NULL; + + if (tmpObj == Py_None) { + Py_INCREF(Py_None); + return Py_None; } - pjsua_normalize_stun_config(cfg); - obj->stun_port1 = cfg->stun_port1; - obj->stun_port2 = cfg->stun_port2; + + obj = (stun_config_Object *) tmpObj; + cfg.stun_port1 = obj->stun_port1; + cfg.stun_port2 = obj->stun_port2; + cfg.stun_srv1.ptr = PyString_AsString(obj->stun_srv1); + cfg.stun_srv1.slen = strlen(PyString_AsString(obj->stun_srv1)); + cfg.stun_srv2.ptr = PyString_AsString(obj->stun_srv2); + cfg.stun_srv2.slen = strlen(PyString_AsString(obj->stun_srv2)); + + pjsua_normalize_stun_config(&cfg); + obj->stun_port1 = cfg.stun_port1; + obj->stun_port2 = cfg.stun_port2; Py_XDECREF(obj->stun_srv1); obj->stun_srv1 = - PyString_FromStringAndSize(cfg->stun_srv1.ptr, cfg->stun_srv1.slen); + PyString_FromStringAndSize(cfg.stun_srv1.ptr, cfg.stun_srv1.slen); Py_XDECREF(obj->stun_srv2); obj->stun_srv2 = - PyString_FromStringAndSize(cfg->stun_srv2.ptr, cfg->stun_srv2.slen); - if (cfg != NULL) - { - free(cfg); - } + PyString_FromStringAndSize(cfg.stun_srv2.ptr, cfg.stun_srv2.slen); + Py_INCREF(Py_None); return Py_None; } -- cgit v1.2.3