summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pjsip-apps/src/py_pjsua/Makefile6
-rw-r--r--pjsip-apps/src/py_pjsua/py_pjsua.c42
2 files changed, 26 insertions, 22 deletions
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;
}