Coccinelle archive mirror
 help / color / mirror / Atom feed
From: Yudi Yang <jy103@rice.edu>
To: cocci@inria.fr
Subject: [cocci] Match and print size of allocation
Date: Fri, 14 Apr 2023 17:36:25 -0500	[thread overview]
Message-ID: <bea8e057-44b0-4ae4-a6cc-b23bd0837270@Spark> (raw)
In-Reply-To: <eccc2924-6657-4776-84f1-3d8413904cf2@Spark>

[-- Attachment #1: Type: text/plain, Size: 379 bytes --]

Hello,

I would like to match the size of allocation, I am wondering if I write the following:

@print@
expression N, SIZE;
@@

(
  malloc(SIZE);
|
  calloc(N, SIZE);
)
+ printf(“Allocation: %d\n", (N) * (SIZE));

I am not sure if I could set the default value for N in the malloc case, or is there anything I should do to make it correct.

Best,
Yudi


[-- Attachment #2: Type: text/html, Size: 1388 bytes --]

       reply	other threads:[~2023-04-15  5:10 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <eccc2924-6657-4776-84f1-3d8413904cf2@Spark>
2023-04-14 22:36 ` Yudi Yang [this message]
2023-04-15  5:40   ` [cocci] Match and print size of allocation Julia Lawall
2023-04-15  5:42   ` Julia Lawall
2023-04-15  6:13 Yudi Yang
2023-04-15  7:31 ` Julia Lawall
2023-04-15 16:40   ` Yudi Yang
2023-04-15 16:53     ` Julia Lawall
2023-04-17 17:48       ` Yudi Yang
     [not found]         ` <alpine.DEB.2.22.394.2304172139580.2883@hadrien>
2023-04-17 23:26           ` Yudi Yang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bea8e057-44b0-4ae4-a6cc-b23bd0837270@Spark \
    --to=jy103@rice.edu \
    --cc=cocci@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).