? Heap corruption on free(...)

I have this enum type:enum Cell { ALIVE='X', DEAD='O' };And I allocate an array with it:h_board = (Cell*) malloc(width*height*sizeof(char));I assume I'm not doing this wrong since Cell values are char
 ? Heap corruption while freeing memory in a recursion function

I'm implementing an algorithm to select Kth smallest element of an array . so far when i was trying to free heap memory i got this error : crt detected that the application wrote to memory after end o
 ? Heap Corruption double freeing memory

I have a Heap corruption crash for an application and so I turned on page heap from gflags and collected a crash dump file for that application.From the dump file I found out that it is due to double
 ? what happens when tried to free memory allocated by heap manager, which allocates more than asked for?

This question was asked to me in an interview.Suppose char *p=malloc(n) assigns more than n,say N bytes of memory are allocated and free(p) is used to free the memory allocated to p. can heap manager
 ? Is this legal ? C++

I have a simple question..Can i allocate and deallocate memory like this in the operator+ for other objectdelete [] p.name; p.name = new char[strlen(a.name) + 1];Look at the operator+class PlDrustvo{p
 ? Expanding the lifetime of a variable

#include <iostream>#include <utility>int main(){ double* ptr; { double temp = 5.5; ptr = new double(std::move(temp)); } // temp dies here std::cout << *pt
 ? changing pointer of a dynamically allocated array

When we declare something dynamically like this int *ptr = new int [100];and then change the pointer address (i.e point it to something else)int pointer[5] = {1,2,1,3,1,};ptr = pointer ; now what happ
 ? Behaviour of dynamically allocated junk data

I was trying to do some "statistics" about junk data, just for fun.However, I came across something I don't understand.Here is my code:int* p;const int limit = 100;for(int i = 0; i < limit; ++i) {
 ? unordered_map: clear() does not release heap on clear()

This question already has an answer here: How can I force the STL memory cache to clear? 2 answers Content of y
 ? Bucket count in unordered_map

In the sample program given below (source: http://www.cplusplus.com/reference/unordered_map/unordered_map/rehash/) // unordered_map::rehash#include <iostream>#include <string>#include <
 ? Is it good practice to NULL a pointer after deleting it?

I'll start out by saying, use smart pointers and you'll never have to worry about this.What are the problems with the following code?Foo * p = new Foo;// (use p)delete p;p = NULL;This was sparked by a
 ? size of dynamically allocated array

Is it true that a pointer assigned to the starting address of a dynamically allocated array does not have the information of the size of the array? So we have to use another variable to store its size
 ? What is Dynamic Memory Allocation in C++?

I'm learning about Dynamic Memory Allocation in C++ and the keywords new and new[] are mentioned.It is said to enable users to specify the size of the memory allocation at runtime, unlike simply decla
 ? What is wrong with using arrays dynamically allocated in C++?

This question already has an answer here: Why should C++ programmers minimize use of 'new'? 17 answers
 ? Deallocating memory in a 2D array

Suppose we have:int** myArray = new int*[100];for(int i = 0; i < 100; i++){ myArray[i] = new int[3];}What is the appropriate way to deallocate this array (which method below, if either is a corr
 ? c++ EOF running one too many times?

This is my first time using EOF and/or files, and I am having an issue where my code hangs, which I believe is because my EOF is looping one too many times.I am imputing from a file, and dynamically c

Page 2 of 4255  |  Show More Pages:  Top Prev Next Last