[OpenSER-Devel] SF.net SVN: openser: [3156] trunk/modules/permissions/mi.c

Bogdan-Andrei Iancu bogdan at voice-system.ro
Mon Nov 19 11:28:38 UTC 2007


Dan Pascu wrote:
> On Monday 19 November 2007, Bogdan-Andrei Iancu wrote:
>   
>> Hi,
>>
>> To solve this potential problem without any change in the MI interface
>> and without no runtime penalties (strlen), I just added a small macro
>> MI_SSTR (MI  Static String) to compute the len of a static string at
>> compile time.
>>
>> With it, instead of having:
>>     add_mi_node_child( rpl, 0, "Server", 6,......
>> you can do:
>>     add_mi_node_child( rpl, 0, MI_SSTR("Server"),.....
>>
>> As a POC, I did the changes on the MI core functions and the permission
>> module.
>>     
>
> I think this is a short term solution to avoid issues, but I do not see it 
> as an ideal solution. The main issue with it is that it hides the 
> interface and makes a 3 argument function look like a 2 argument one in 
> the code. 
That is true, but I do not find it a major issue.
> I still believe that after 1.3 we should make that function 
> receive a char* only and compute the length internally because a str 
> doesn't help here
I most of the case, the MI functions gets as info from either static 
strings (with known len), either str* values (again with known len).
I see no logic to recalculate the len even if 70% you already know it.
To be honest, I'm not in favour of easy coding and nice interfaces, but 
with no performance concerns.
>  and the macro computes strlen(_s) so there will be no 
> runtime penalty anyway.
>   
The macro uses sizeof() which is replaced at compile time with the size 
of the string. No strlen is done.

Regards,
Bogdan




More information about the Devel mailing list