Re: Why does octstr_cat() require ostr1 to be non-immutable?

2017-01-10 Thread amalysh
Hi,

I fixed it in SVN.

Thanks,
Alex


> Am 22.12.2016 um 12:04 schrieb amal...@kannel.org:
> 
> Hi Werner,
> 
> as far as I see there is no reason to immutable assert.
> 
> Alex
> 
> 
>> Am 21.12.2016 um 15:39 schrieb Werner Coetzee > >:
>> 
>> Hi
>>  
>> Why does the octstr_cat(Octstr *ostr1, Octstr *ostr2) function in 
>> gwlib/octstr.c require that ostr1 be non-immutable?
>> It contains:
>> gw_assert(!ostr1->immutable);
>>  
>> I can't see any reason for the requirement since ostr1 is never modified in 
>> octstr_cat() so to me octstr_cat() should work perfectly fine/safely if 
>> ostr1 is immutable.
>> And since the requirement is there for ostr1, why is it not there for ostr2? 
>>  There's no difference in the way that ostr1 and ostr2 is used.
>>  
>> I now have to resort to much slower functions such as octstr_format or 
>> octstr_insert or octstr_append to get the same result.
>>  
>> My use case:
>>  
>> void myfunc(const Octstr *param) // param should/will not be modified
>> {
>> Octstr *newvar = octstr_cat(octstr_imm("PREFIX"), param);  // this will 
>> panic
>> // Do something with newvar
>> }
>>  
>> So my work around is newvar = octstr_format("%s%S", "PREFIX", param); but 
>> could also have newvar = octstr_create("PREFIX"); octstr_append(newvar, 
>> param); or even newvar = octstr_duplicate(param); octstr_insert(newvar, 
>> octstr_imm("PREFIX"), 0);
>>  
>> I would really appreciate it if someone could shed some light on this, and 
>> if the powers that be agree with me remove the assertion?
>>  
>> Thanks in advance
>> Werner
>>  
>> 
>>   
>> 
>> Werner Coetzee
>> Senior Message Engine Engineer
>> 
>>  
>> T  +27 21 910 7700
>> werner.coet...@clickatell.com 
>> www.clickatell.com 
>> 
> 



Re: Why does octstr_cat() require ostr1 to be non-immutable?

2016-12-25 Thread Rene Kluwen

First of all, let me say that I agree with you.
But a possible way of thinking could have been to make octstr_cat make 
like (or look like) strcat().


== Rene

-- Origineel bericht --
Van: "Werner Coetzee" <werner.coet...@clickatell.com>
Aan: "devel@kannel.org" <devel@kannel.org>
Verzonden: 21-12-2016 15:39:50
Onderwerp: Why does octstr_cat() require ostr1 to be non-immutable?


Hi



Why does the octstr_cat(Octstr *ostr1, Octstr *ostr2) function in 
gwlib/octstr.c require that ostr1 be non-immutable?


It contains:

gw_assert(!ostr1->immutable);



I can't see any reason for the requirement since ostr1 is never 
modified in octstr_cat() so to me octstr_cat() should work perfectly 
fine/safely if ostr1 is immutable.


And since the requirement is there for ostr1, why is it not there for 
ostr2?  There's no difference in the way that ostr1 and ostr2 is used.




I now have to resort to much slower functions such as octstr_format or 
octstr_insert or octstr_append to get the same result.




My use case:



void myfunc(const Octstr *param) // param should/will not be modified

{

Octstr *newvar = octstr_cat(octstr_imm("PREFIX"), param);  // this 
will panic


// Do something with newvar

}



So my work around is newvar = octstr_format("%s%S", "PREFIX", param); 
but could also have newvar = octstr_create("PREFIX"); 
octstr_append(newvar, param); or even newvar = octstr_duplicate(param); 
octstr_insert(newvar, octstr_imm("PREFIX"), 0);




I would really appreciate it if someone could shed some light on this, 
and if the powers that be agree with me remove the assertion?




Thanks in advance

Werner




  Werner CoetzeeSenior Message Engine Engineer T  +27 21 910 
7700werner.coet...@clickatell.comwww.clickatell.com 
<https://www.clickatell.com>


Re: Why does octstr_cat() require ostr1 to be non-immutable?

2016-12-22 Thread amalysh
Hi Werner,

as far as I see there is no reason to immutable assert.

Alex


> Am 21.12.2016 um 15:39 schrieb Werner Coetzee :
> 
> Hi
>  
> Why does the octstr_cat(Octstr *ostr1, Octstr *ostr2) function in 
> gwlib/octstr.c require that ostr1 be non-immutable?
> It contains:
> gw_assert(!ostr1->immutable);
>  
> I can't see any reason for the requirement since ostr1 is never modified in 
> octstr_cat() so to me octstr_cat() should work perfectly fine/safely if ostr1 
> is immutable.
> And since the requirement is there for ostr1, why is it not there for ostr2?  
> There's no difference in the way that ostr1 and ostr2 is used.
>  
> I now have to resort to much slower functions such as octstr_format or 
> octstr_insert or octstr_append to get the same result.
>  
> My use case:
>  
> void myfunc(const Octstr *param) // param should/will not be modified
> {
> Octstr *newvar = octstr_cat(octstr_imm("PREFIX"), param);  // this will 
> panic
> // Do something with newvar
> }
>  
> So my work around is newvar = octstr_format("%s%S", "PREFIX", param); but 
> could also have newvar = octstr_create("PREFIX"); octstr_append(newvar, 
> param); or even newvar = octstr_duplicate(param); octstr_insert(newvar, 
> octstr_imm("PREFIX"), 0);
>  
> I would really appreciate it if someone could shed some light on this, and if 
> the powers that be agree with me remove the assertion?
>  
> Thanks in advance
> Werner
>  
> 
>   
>  
> Werner Coetzee
> Senior Message Engine Engineer
> 
>  
> T  +27 21 910 7700
> werner.coet...@clickatell.com 
> www.clickatell.com 
> 



Why does octstr_cat() require ostr1 to be non-immutable?

2016-12-21 Thread Werner Coetzee
Hi

Why does the octstr_cat(Octstr *ostr1, Octstr *ostr2) function in 
gwlib/octstr.c require that ostr1 be non-immutable?
It contains:
gw_assert(!ostr1->immutable);

I can't see any reason for the requirement since ostr1 is never modified in 
octstr_cat() so to me octstr_cat() should work perfectly fine/safely if ostr1 
is immutable.
And since the requirement is there for ostr1, why is it not there for ostr2?  
There's no difference in the way that ostr1 and ostr2 is used.

I now have to resort to much slower functions such as octstr_format or 
octstr_insert or octstr_append to get the same result.

My use case:

void myfunc(const Octstr *param) // param should/will not be modified
{
Octstr *newvar = octstr_cat(octstr_imm("PREFIX"), param);  // this will 
panic
// Do something with newvar
}

So my work around is newvar = octstr_format("%s%S", "PREFIX", param); but could 
also have newvar = octstr_create("PREFIX"); octstr_append(newvar, param); or 
even newvar = octstr_duplicate(param); octstr_insert(newvar, 
octstr_imm("PREFIX"), 0);

I would really appreciate it if someone could shed some light on this, and if 
the powers that be agree with me remove the assertion?

Thanks in advance
Werner



[cid:image1a2972.PNG@6b9549b0.4bb1f1fc]

Werner Coetzee
Senior Message Engine Engineer

[cid:imagea0c2e2.PNG@e6899d94.4bbd3821]


T  +27 21 910 7700
werner.coet...@clickatell.com
www.clickatell.com



[cid:imagedf67b0.PNG@9e9eeaf0.4fa80643]