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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T19:43:12+00:00 2026-05-17T19:43:12+00:00

Assume I have some C++ method which returns back a pointer to an object.

  • 0

Assume I have some C++ method which returns back a pointer to an object. Something in the header file that looks like this:

uint8_t* getData(void);

This guy returns a byte array, but there is nothing that says if this is a dynamic or statically generated piece of data (local to the class or created with new).

Is there a specific naming convention in C++ to distinguish between methods that return memory that is dynamically allocated (and so must be deleted by the requester), vs methods that just return a reference to a statically define piece of data?

What is the preferred way to do this, or does it depend on the situation?

  • 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-17T19:43:13+00:00Added an answer on May 17, 2026 at 7:43 pm

    My conventions are:

    uint8_t* getData();
    

    is statically allocated, or at least it’s not my responsibility for deleting this data. However if it’s an array I would write:

    pair<uint8_t*,uint8_t*> getData();
    

    Or define a container for that.

    auto_ptr<uint8_t> getData();
    unique_ptr<uint8_t> getData();
    

    allocates single object and I own it from now on.

    shared_ptr<uint8_t> getData();
    

    allocates single object with shared ownership.

    vector<uint8_t> getData();
    

    allocates an array, vector owns the memory.

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

Sidebar

Related Questions

Let's assume that we have a controller with some action which could look like:
So I have a class that looks something like the following: public class MyClass
Assume I have the following input in Pig: some And I would like to
Let's assume I have a framework written in Java and some C++ code which
Assume some domain and view objects (that have no common base class) public class
Lets assume i have a function that takes 32bit integer in, and returns random
I have a TSV file that consists of integers along with some false data
I would like to have a way to specify for certain Javascript method which
Assume, we have something like: val x = foo.charAt(0) and let us further assume,
Assume you have a function read_key and normally it does some stuff. You someone

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.