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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T11:04:41+00:00 2026-06-17T11:04:41+00:00

Let’s assume I want to use a library that contains these 2 headers: //

  • 0

Let’s assume I want to use a library that contains these 2 headers:

// types.h
typedef const char* Value;
typedef const char* Key;

// map.h
/** The given name and value will be copied into the map */
void add(struct Map* m, Key key, Value value);

I’m assuming the comment means that the contents of the char*s key and value will be copied by the add function, and it won’t store the pointers for use after it has returned. That means the calling function can do whatever it wants with those pointers, like e.g. freeing key and value, immediately after calling add.

The calling function can also expect that add will not modify key or value.

Now what would the experienced C programmer assume about these ownership issues if that comment wasn’t there and neither sources of the implementation nor a usage example were available?

  • 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-17T11:04:42+00:00Added an answer on June 17, 2026 at 11:04 am

    First & foremost is to try & get the documentation. One cannot be 100% sure unless the API documents the behavior. If all attempts fail then it is reasonable to assume that:

    1. Function does not modify either Key or Value since they are passed as const.
    2. Unless explicitly mentioned the caller retains the ownership of the variables being passed to the function and can do whatever they want with the passed Key and Value after the function call.

    Also, One should confirm the assumptions with rigorous testing.

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

Sidebar

Related Questions

Let say I want to create an iOS app that download music files from
Let's say you have a class library project that has any number of supplemental
Let's say I want to write a function that validates an email address with
Let's say that each Product has a category. I want to ask the Users
Let say I have my view that I use it as a toggle button.
Let us assume the code I use to iterate through a node list foreach(XmlNode
Let's assume I want to deserialize this (I've removed the namespaces to make things
Let's assume I have the following typedef: typedef void (^myBlock)(id); And I have some
Let's say I want to use Breeze to create a Task entity (I'm using
Let's say I don't have photoshop, but I want to make pattern files (.pat)

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.