On 5 January 2012 13:51, Robert Gomulka <[email protected]> wrote:
> On 5 January 2012 13:18, SF Markus Elfring
> <[email protected]> wrote:
>>> Could you elaborate more?
>>
>>
>> Yes, of course.
>>
>> How do you think about the following pattern to cope with more name
>> variations for memory allocation functions?
>>
>> @@
>> identifier malloc =~ "\(m\|c\|re\|kc\|kz\)alloc$";
>> @@
>>
>>
>> Would also like to handle Windows memory management functions?
>> http://msdn.microsoft.com/en-gb/site/aa366781
>>
>> Regards,
>> Markus
>
> Well,
> as I said before, I have to handle only a bunch of names. My question
> was only regarding the way of writing the checker, now I think I would
> be able to extend it if needed, using regular expressions.
>
> Thanks anyway for the suggestion.
>
> Best regards,
> Robert

Btw.
please note that calloc and realloc have different number and type of arguments.

I've created something like that for them:
@@
type T;
identifier malloc =~ "malloc$";
T *x;
@@

 malloc(
-  x
+  *(x)
 )

@@
type T2, T3;
identifier calloc =~ "calloc$";
T2 *y;
T3 *z;
@@

 calloc(
-  y
+  *(y)
 ,
- z
+ *(z)
 )

@@
type T4;
identifier realloc =~ "realloc$";
T4 *w;
@@

 realloc( ... ,
-  w
+  *(w)
 )


I guess it might be simplified, but that's enough for my purposes.

Best regards,
Robert
_______________________________________________
Cocci mailing list
[email protected]
http://lists.diku.dk/mailman/listinfo/cocci
(Web access from inside DIKUs LAN only)

Reply via email to