473,395 Members | 1,870 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

reallocate extra memory

Hi everyone,

I had allocated from memory for a character array using the new
operator in cpp. Now i want to increase this allocation dynamically,
realloc() works with memory allocated by malloc(), does it work with
memory allocated by new? If not, is there any operator that can do the
same in c plus plus?

Thanks in advance ! ! !
Mar 24 '08 #1
2 1763
Rahul wrote:
Hi everyone,

I had allocated from memory for a character array using the new
operator in cpp. Now i want to increase this allocation dynamically,
realloc() works with memory allocated by malloc(), does it work with
memory allocated by new? If not, is there any operator that can do the
same in c plus plus?
No. The only thing you can ho with objects allocated with new is to
allocate a larger chunk and copy the original chunk's content.
Mar 24 '08 #2
Rahul wrote:
I had allocated from memory for a character array using the new
operator in cpp. Now i want to increase this allocation dynamically,
realloc() works with memory allocated by malloc(), does it work with
memory allocated by new? If not, is there any operator that can do the
same in c plus plus?
No, but you can use std::vector<charinstead of a raw pointer.
Best

Kai-Uwe Bux
Mar 24 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Jon Perez | last post by:
Running the following under Linux creates 3 processes instead of 2. Once the started thread exits, 2 processes still remain. Why? import thread from thread import start_new_thread def...
0
by: A.M. de Jong | last post by:
Hi, We have placed extra internal memory (from 2 to 3.6 GigaByte) In SQL Service enterprise manager I can see this. (Some propertie screen). But we use spotlight as a monitor tool and in...
8
by: Gernot Frisch | last post by:
std::deque<intd; d.push_front(13); int* p13 = &d.begin(); d.push_front(1); d.push_back(2); Can I be safe, that p13 points to 13? I mean, unless I erase the 13, of course.
18
by: happyvalley | last post by:
Hi, basically, the test function get a char pointer, and assigned a string to it. then the string is passed back by the call-by-reference mechanism. in test(), I reallocate some memory for the...
11
by: Piotrek | last post by:
Hi, I have no idea why my reallocation function (myadd) is breaking up my array. I'm trying to solve it and it took me few hours already. Maybe you can look at my code and explain me what is...
14
by: karthikbalaguru | last post by:
Hi, In the case of heap , to keep track of a single chunk of memory it requires 8 bytes of information. That is, it requires 4 bytes to hold the size, and 4 bytes to hold the pointer to the next...
4
by: erktek | last post by:
#include <stdio.h> #include <string.h> #include <stdlib.h> int main(int argc, char* argv) { int i; int a; int *p = NULL;
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.