Uploaded image for project: 'Qpid Proton'
  1. Qpid Proton
  2. PROTON-726

Macros to wrap malloc(), realloc(), free()

Attach filesAttach ScreenshotAdd voteVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Open
    • Trivial
    • Resolution: Unresolved
    • proton-0.8
    • proton-c-future
    • proton-c
    • None

    Description

      As we are porting ProtonC across various platforms, we take the trunk code and use it in a specific project. I would like to be able to take any newer version from SVN and use it, without the need to modify it each every time, to suit the target system specifics.
      Therefore, I would like to kindly ask for an official support of macros to replace the memory allocation functions.

      Create a single global header file (or reuse some existing one, like the platform.h), and add a three new macros to it.
      Having macros in place of general malloc(), realloc() and free() calls, will allow to keep the ported version easily update-able when new ProtonC version comes out (there won't be no need to manually go through all the files and replacing the calls with other calls).

      For Linux (or Windows), the macros will directly link to the default functions.
      For other OS(es), the developer will be able to just rewrite three lines of code and be all set.

      Example:
      pn_buffer_t *buf = (pn_buffer_t *)malloc(sizeof(pn_buffer_t));
      will get replaced with something like this
      pn_buffer_t *buf = (pn_buffer_t *)MALLOC_MACRO(sizeof(pn_buffer_t));
      where (for Linux) it will be:
      #define MALLOC_MACRO malloc
      or for other OS it might then be:
      #define MALLOC_MACRO customMalloc

      Of course, I do not care about the naming of the macros, or the actual code style.
      I will leave all this on the official developers, I just ask to get such a functionality in.
      This change should have no impact on functionality, code size or speed.

      Attachments

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            Unassigned Unassigned
            E528527 German Shepherd (PrE)

            Dates

              Created:
              Updated:

              Slack

                Issue deployment