Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7509479
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T22:55:48+00:00 2026-05-29T22:55:48+00:00

A co-worker asked me to explain a bit of C code in memcached .

  • 0

A co-worker asked me to explain a bit of C code in memcached. I am at the point where I admit I do not understand it either.

It has to do with C function-like macro definitions with parameters that do not also have a replacement list. For example, starting at line 2751 in memcached.c:

            if (return_cas)
            {
              MEMCACHED_COMMAND_GET(c->sfd, ITEM_key(it), it->nkey,
                                    it->nbytes, ITEM_get_cas(it));
              /* Goofy mid-flight realloc. */
              if (i >= c->suffixsize) {
                char **new_suffix_list = realloc(c->suffixlist,
                                       sizeof(char *) * c->suffixsize * 2);
                if (new_suffix_list) {
                    c->suffixsize *= 2;
                    c->suffixlist  = new_suffix_list;

MEMCACHED_COMMAND_GET() is defined on line 23 in trace.h:

#define MEMCACHED_COMMAND_GET(arg0, arg1, arg2, arg3, arg4)

C macro function-like definition with arguments, ok. No replacement list.

The output of cpp on memcached.c shows the function-like macro turns into ‘;’:

# 2751 "memcached.c"
            if (return_cas)
            {
              ;


              if (i >= c->suffixsize) {
                char **new_suffix_list = realloc(c->suffixlist,
                                       sizeof(char *) * c->suffixsize * 2);
                if (new_suffix_list) {
                    c->suffixsize *= 2;
                    c->suffixlist = new_suffix_list;

Does anyone have any insight into why a programmer would include function-like macros without a replacement list like MEMCACHED_COMMAND_GET() that have no effect on the code produced? What purpose is being served by doing doing this? Thank you kindly in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T22:55:49+00:00Added an answer on May 29, 2026 at 10:55 pm

    On Solaris and Mac OSX it’s replaced to triggering a DTrace probe so it expands to something else.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

A co-worker asked about some code like this that originally had templates in it.
A co worker of mine asked me to review some of my code and
Sorry folks but I asked a question earlier and perhaps did not explain myself
In a previous question I asked how to improve a bit of code. It
I have a co-worker that asked me why he has to use the ICommand
A co-worker asked me to change a signature from using a primitive boolean to
A coworker showed me the following code and asked me why it worked. <span
this has been asked before on WP forums, but none of the solutions worked
I guess this question has been asked a lot around. I know Rails can
When asked by the admin, my Heroku worker generates a report, compressed as a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.