I see...in the end my suggestion pretty much is the same as your approach has been, anyways...it boils down for you to use a temporary pool for allocating the header objects, putting them into the config, and release the pool after the account modification, since (As most of the time) parameters from methods are duplicated, so no need to keep the memory allocated.
so basically the pjsua_pool_create/release suggestion is the only one left (:
Regards,
Harry
Gesendet: Donnerstag, 26. Mai 2016 um 14:37 Uhr
Von: "Colin Morelli" <colin.morelli@xxxxxxxxx>
An: "pjsip list" <pjsip@xxxxxxxxxxxxxxx>
Betreff: Re: Custom Registration Header
Von: "Colin Morelli" <colin.morelli@xxxxxxxxx>
An: "pjsip list" <pjsip@xxxxxxxxxxxxxxx>
Betreff: Re: Custom Registration Header
Harry,
Thanks for the response. I'm actually rebuilding a new config from scratch so I'm not using the get config method. I'll look into your other suggestions as well.
When setting the account config I'm assuming it all gets copied into the account pool's memory, right? I'm going to have to update the config with new registration headers somewhat frequently so I want to avoid any leaks.
Best,
Colin
_______________________________________________ Visit our blog: http://blog.pjsip.org pjsip mailing list pjsip@xxxxxxxxxxxxxxx http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org
Thanks for the response. I'm actually rebuilding a new config from scratch so I'm not using the get config method. I'll look into your other suggestions as well.
When setting the account config I'm assuming it all gets copied into the account pool's memory, right? I'm going to have to update the config with new registration headers somewhat frequently so I want to avoid any leaks.
Best,
Colin
On Thu, May 26, 2016 at 6:16 AM Harald Radke <harryrat@xxxxxx> wrote:
hm... I dont use the sua abstraction, however, I assume you retrieved your account config via pjsua_acc_get_config()? for that you needed a pool anyways, maybe you can combine config getting and adjusting?also, pjsua_pool_create/release() spares you the caching pool handling I guess.Regards,HarryGesendet: Donnerstag, 26. Mai 2016 um 05:25 Uhr
Von: "Colin Morelli" <colin.morelli@xxxxxxxxx>
An: "pjsip list" <pjsip@xxxxxxxxxxxxxxx>
Betreff: Re: Custom Registration HeaderOk, so I managed to get it working, but I'm far from being great with this so I'd really appreciate feedback on my approach. Basically I'm running:pj_caching_pool cp;pj_caching_pool_init(&cp, &pj_pool_factory_default_policy, 0);pj_pool_t *pool = pj_pool_create(&cp.factory, "header", 1000, 1000, NULL);[self convertAccountConfiguration:configuration config:&config pool:pool]; // this is the method that sets headers by allocating from the provided poolpjsua_acc_modify((int) _id, &config);pj_pool_release(pool);Is that acceptable? Is there a better approach?On Wed, May 25, 2016 at 9:57 PM Colin Morelli <colin.morelli@xxxxxxxxx> wrote:If it makes any difference, I'm actually looking to have this header change on every registration request. The use case is to include a JWT in the registration (instead of a standard username and password)Thanks,ColinOn Wed, May 25, 2016 at 9:54 PM Colin Morelli <colin.morelli@xxxxxxxxx> wrote:Hey all,I'm trying to send a custom header in my registration request. However, my app always ends up crashing when trying to set it. I'm calling:pj_list_init(&config->reg_hdr_list);pjsip_generic_string_hdr generic_hdr;pj_str_t name = pj_str("name");pj_str_t value = pj_str("value");pjsip_generic_string_hdr_init2(&generic_hdr, &name, &value);pj_list_push_back(&config->reg_hdr_list, &generic_hdr);The backtrace from the crash is:frame #0: 0x348dcae6 libsystem_platform.dylib`_platform_memmove + 486frame #1: 0x347ebc64 libsystem_c.dylib`__memcpy_chk + 16frame #2: 0x347ebc64 libsystem_c.dylib`__memcpy_chk + 16frame #3: 0x0026f34a MyApp`pj_memcpy + 26frame #4: 0x0026f31c MyApp`pj_strdup + 68frame #5: 0x002c58f2 MyApp`pjsip_generic_string_hdr_init + 38frame #6: 0x002c5948 MyApp`pjsip_generic_string_hdr_create + 36frame #7: 0x002c6d1c MyApp`pjsip_generic_string_hdr_clone + 24frame #8: 0x002c4d62 MyApp`pjsip_hdr_clone + 34frame #9: 0x00301aae MyApp`pjsua_acc_config_dup + 420frame #10: 0x00301e68 MyApp`pjsua_acc_add + 666I'm assuming I need to be allocating the strings on the pool but I'm not sure which pool to use without causing a leak.Best,Colin______________________________________________________________________________________________ Visit our blog: http://blog.pjsip.org pjsip mailing list pjsip@xxxxxxxxxxxxxxx http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org
Visit our blog: http://blog.pjsip.org
pjsip mailing list
pjsip@xxxxxxxxxxxxxxx
http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org
_______________________________________________ Visit our blog: http://blog.pjsip.org pjsip mailing list pjsip@xxxxxxxxxxxxxxx http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org