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 9170857
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T16:05:05+00:00 2026-06-17T16:05:05+00:00

When writing an Erlang C NIF, how can a pointer, created in C let’s

  • 0

When writing an Erlang C NIF, how can a pointer, created in C let’s say an array, be returned to Erlang for later use by the same Erlang process in another NIF call?

 #define LENGTH = 50;

 int *a, array[LENGTH];

 a = enif_alloc(LENGTH * sizeof(int));

It should be a pointer that can be returned or even stored so that when I return to the NIF from within the same Erlang process I can access the pointer and the memory referenced by it.

  • 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-17T16:05:06+00:00Added an answer on June 17, 2026 at 4:05 pm

    In this particular case, I would use enif_alloc_resource. Create a struct to contain your pointer and establish it as a resource object.

    You could also encode it as a binary, but I would recommend against that, as it would allow erlang functions to modify the contents before passing it back in. Resource types are opaque from the erlang side and cannot be modified.

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

Sidebar

Related Questions

I'm writing some Erlang code and I'm very unsure whether I should let everything
I am writing a markdown compiler in Erlang for server-side use. Because it will
I am in the process of writing my first erlang application and I don't
Im writing an Erlang C NIF that will only be used by one Erlang
How do I concatenate two binaries in Erlang? For example, let's say I have:
I am writing an erlang module that has to deal a bit with strings,
Writing htaccess that allows me to remove index.php from the URL can confuse search
I'm exploring the possibility of writing an application in Erlang, but it would need
I'm writing EUnit tests for Erlang code. I have a source module: -module(prob_list). -export([intersection/2,union/2]).
I'm writing a mapreduce query in erlang for Riak and I want to pass

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.