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

  • SEARCH
  • Home
  • 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 8325021
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T00:17:21+00:00 2026-06-09T00:17:21+00:00

I am trying to compile a toolkit on mac. It has a reference to

  • 0

I am trying to compile a toolkit on mac. It has a reference to memalign function of malloc.h, but the only close function I could find for mac is posix_memalign. So I am trying to wrap posix_memalign to look like memalign.

I am a bit confused about how to do this (because of the void* and void** pointers):

The signature for posix_memalign is

int posix_memalign(void **memptr, size_t alignment, size_t size); 

and the signature for memalign is:

void *memalign(size_t blocksize, size_t bytes);

Any pointers much appreciated. ( Lame pun accidental! 🙂

thanks

  • 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-06-09T00:17:25+00:00Added an answer on June 9, 2026 at 12:17 am

    Something like:

    void *memalign(size_t blocksize, size_t bytes) {
      void *result=0;
      posix_memalign(&result, blocksize, bytes);
      return result;
    }
    

    The &result will get you a void** to call posix_memalign with and then you can return the result as memalign did.

    One point to note: this doesn’t quite match the behaviour – memalign returns errors via errno, but posix_memalign returns them as an int and doesn’t touch errno. You should see to it that errors are handled appropriately somehow still.

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

Sidebar

Related Questions

I am trying to compile a code that has a malloc function inside the
Im trying to compile but im getting these errors: 1>.\item.cpp(123) : warning C4800: 'int'
I'm trying to compile fastboot for Android using this guide , but I'm getting
Trying to compile a project using the Newtonsoft.Json.WindowsPhone reference and I am gettign 2
When trying to compile a solution that contains a project with a reference to
Trying to compile a unity3d project in xcode but i'm getting the following compile
Just trying to compile some trivial Haskell, but its not finding the c runtimes,
We're trying to compile a project with MinGW on the machine that has both
trying to compile old project that has many uses of shared_ptr with the vs2010.
Trying to compile a iPhone/iPad application with SDK3.2 and am getting this error: Undefined

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.