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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T15:14:16+00:00 2026-05-23T15:14:16+00:00

Note that the question has been changed and no longer matches the answers I’m

  • 0

Note that the question has been changed and no longer matches the answers

I’m trying to create memory to hold a buffer of floats (here, 4 floats).
I’ve allocated the memory, and all the 4 values in the memory are zero.

The loop of course iterates 4 times, but the 4th time moves ptr to outside the memory that I’ve allocated. So at the end of the loop I move ptr back to where I allocated the memory, and use delete[].

My question is: Is the entire 4-float buffer being deleted when I call delete[]? (this is obviously what I need!)

int inFramesToProcess = 4;
float *ptr = new float[inFramesToProcess]();

    for(UInt32 i = 0; i < inFramesToProcess; ++i) {
        ptr++;
    }

    ptr -= inFramesToProcess;

delete[] ptr; 
  • 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-23T15:14:16+00:00Added an answer on May 23, 2026 at 3:14 pm

    Copy the pointer before you increment it.

    int inFramesToProcess = 4;
    float *ptr = new float[inFramesToProcess]();
    float *ptr_copy = ptr;
    
        for(UInt32 i = 0; i < inFramesToProcess; ++i) {
            ptr_copy++;
        }
    
    delete[] ptr;
    

    Or just don’t use pointers for dynamic arrays, use a vector instead. Then you don’t have to worry about deleting.

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

Sidebar

Related Questions

A foreword note that this is for an assignment. A question has already been
NOTE: This question has been updated to provide more detail and insight than the
Apologies if this question has been asked before. I'm hoping that someone can step
NOTE: Updated and rewritten This question has been redone and updated. Please pardon outdated
I've got a follow up question to my question that has been answered by
(note that this question is not about CAS, it's about the May fail spuriously
Please note that this question is from 2008 and now is of only historic
[Please note that this is a different question from the already answered How to
(Please note that I have seen a similar question on StackOverflow recently, however I
Since I posted this question, this issue has resolved itself. There must have been

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.