Ignore:
Timestamp:
Sep 17, 2007 3:44:47 PM (17 years ago)
Author:
bennylp
Message:

Updated pjsua_app.py Python sample application to the new changes in Python module (thanks Gideon Klompje)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjsip-apps/src/py_pjsua/py_pjsua.h

    r1430 r1438  
    2929    pj_str_t str; 
    3030 
    31     str.ptr = PyString_AS_STRING(obj); 
    32     str.slen = PyString_GET_SIZE(obj); 
     31    if (obj) { 
     32        str.ptr = PyString_AS_STRING(obj); 
     33        str.slen = PyString_GET_SIZE(obj); 
     34    } else { 
     35        str.ptr = NULL; 
     36        str.slen = 0; 
     37    } 
    3338 
    3439    return str; 
     
    19061911                                                    cfg->force_contact.slen); 
    19071912    Py_XDECREF(obj->proxy); 
    1908     obj->proxy = (PyListObject *)PyList_New(8); 
     1913    obj->proxy = (PyListObject *)PyList_New(0); 
    19091914    for (i=0; i<cfg->proxy_cnt; ++i) { 
    19101915        PyObject * str; 
    19111916        str = PyString_FromStringAndSize(cfg->proxy[i].ptr,  
    19121917                                         cfg->proxy[i].slen); 
    1913         PyList_SetItem((PyObject *)obj->proxy, i, str); 
     1918        PyList_Append((PyObject *)obj->proxy, str); 
    19141919    } 
    19151920 
     
    19171922 
    19181923    Py_XDECREF(obj->cred_info); 
    1919     obj->cred_info = (PyListObject *)PyList_New(8); 
     1924    obj->cred_info = (PyListObject *)PyList_New(0); 
    19201925    for (i=0; i<cfg->cred_count; ++i) { 
    19211926        PyObj_pjsip_cred_info * ci; 
     
    19241929             PyObj_pjsip_cred_info_new(&PyTyp_pjsip_cred_info,NULL,NULL); 
    19251930        PyObj_pjsip_cred_info_import(ci, &cfg->cred_info[i]); 
    1926         PyList_SetItem((PyObject *)obj->cred_info, i, (PyObject *)ci); 
     1931        PyList_Append((PyObject *)obj->cred_info, (PyObject *)ci); 
    19271932    } 
    19281933 
     
    19921997            return NULL; 
    19931998        } 
    1994         self->proxy = (PyListObject *)PyList_New(8); 
     1999        self->proxy = (PyListObject *)PyList_New(0); 
    19952000        if (self->proxy == NULL) { 
    19962001            Py_DECREF(self); 
    19972002            return NULL; 
    19982003        } 
    1999         self->cred_info = (PyListObject *)PyList_New(8); 
     2004        self->cred_info = (PyListObject *)PyList_New(0); 
    20002005        if (self->cred_info == NULL) { 
    20012006            Py_DECREF(self); 
Note: See TracChangeset for help on using the changeset viewer.