[A better subject line might be "memory pool best practices".]
What is the best way to allocate SIP headers to pass to
pjsua_call_make_call()? I have a map of SIP header-value pairs. I don't
know whether to allocate pjsip_generic_string_hdr from a pool or to use
new(). Please advise me.
If I use a pool, is it one pool per call or one pool for all calls? If
it's a shared pool, can I reuse the pjsip_generic_string_hdr in it? Does
the pool take care of that for me?
If I allocate pjsip_generic_string_hdr myself, when can I free() them?
When pjsua_call_make_call() returns? In my on_stream_destroyed callback?
Dave
I do not think you have to be concerned about memory pool allocation for headers in an outgoing call. Pjsip will duplicate what you pass in msg_data.
So, something like below will be ok (disclaimer for typos):
pj_str_t hdr_text = pj_str(“my header value”);
pjsua_msg_data msg_data;
pjsip_generic_string_hdr hdr;
pjsip_generic_string_hdr_init2(hdr, &MY_GENERIC_HDR_NAME, &hdr_text);
pj_list_push_back(&msg_data->hdr_list, hdr);
pjsua_call_make_call(account, &to, NULL, NULL, &msg_data, &call_id);
Johan
From: pjsip on behalf of David Talmage
Reply-To: pjsip list
Date: Wednesday 7 September 2016 at 21:36
To: "pjsip@lists.pjsip.orgmailto:pjsip@lists.pjsip.org"
Subject: [pjsip] SIP header allocation for pjsua_call_make_call()
[A better subject line might be "memory pool best practices".]
What is the best way to allocate SIP headers to pass to pjsua_call_make_call()? I have a map of SIP header-value pairs. I don't know whether to allocate pjsip_generic_string_hdr from a pool or to use new(). Please advise me.
If I use a pool, is it one pool per call or one pool for all calls? If it's a shared pool, can I reuse the pjsip_generic_string_hdr in it? Does the pool take care of that for me?
If I allocate pjsip_generic_string_hdr myself, when can I free() them? When pjsua_call_make_call() returns? In my on_stream_destroyed callback?
Dave
Este mensaje y sus adjuntos se dirigen exclusivamente a su destinatario, puede contener información privilegiada o confidencial y es para uso exclusivo de la persona o entidad de destino. Si no es usted. el destinatario indicado, queda notificado de que la lectura, utilización, divulgación y/o copia sin autorización puede estar prohibida en virtud de la legislación vigente. Si ha recibido este mensaje por error, le rogamos que nos lo comunique inmediatamente por esta misma vía y proceda a su destrucción.
The information contained in this transmission is privileged and confidential information intended only for the use of the individual or entity named above. If the reader of this message is not the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this transmission in error, do not read it. Please immediately reply to the sender that you have received this communication in error and then delete it.
Esta mensagem e seus anexos se dirigem exclusivamente ao seu destinatário, pode conter informação privilegiada ou confidencial e é para uso exclusivo da pessoa ou entidade de destino. Se não é vossa senhoria o destinatário indicado, fica notificado de que a leitura, utilização, divulgação e/ou cópia sem autorização pode estar proibida em virtude da legislação vigente. Se recebeu esta mensagem por erro, rogamos-lhe que nos o comunique imediatamente por esta mesma via e proceda a sua destruição
On Wed, Sep 7, 2016 at 3:59 PM, JOHAN LANTZ johan.lantz@telefonica.com wrote:
I do not think you have to be concerned about memory pool allocation for
headers in an outgoing call. Pjsip will duplicate what you pass in msg_data.
...
pjsua_call_make_call(account, &to, NULL, NULL, &msg_data, &call_id);
...
Excellent! That's what I needed. I took another look at the source
and I found it to be true: pjsua_call_make_call() makes a copy of
msg_data.
Thanks, Johan!
Dave