I have a very frustrating problem. My application runs on a few machines flawlessly for a month.
However, there is one machine on which my application crashes nearly every day because of segfault.
It always crashes at the same instruction…
I'm in the middle of a project and I'm trying to use malloc() and realloc(). I know when I malloc, it works, but when I use realloc, it doesn't change the amount of alloced memory at all. I've always though that realloc will re-allocate your…
I have been working on a project for some time now, and I decided to make the jump to ARC.
I came across some code that was bombing out every time, and I would like to know why. I have managed to simplify it down to this snippet:
typedef __strong id…
I am writing some code that needs to read fasta files, so part of my code (included below) is a fasta parser. As a single sequence can span multiple lines in the fasta format, I need to concatenate multiple successive lines read from the file into a…
Is there a linux equivalent of _aligned_realloc?
I want to use realloc so I don't have to memcpy the data every time I resize it. Am I stuck with mmap? I only used mmap once is there a recommended way of implementing memory that will be resized a…
Here, in this question, it's stated that there is no realloc-like operator or function in c++. If you wish to resize an array, just just std::vector instead. I've even seen Stroustrup saying the same thing here.
I believe it's not hard to implement…
I have this array of structs and this function takes a pointer to the pointer of the array. The original size is 2, so whenever it reaches the size, I need to realloc and double the size. When this code runs, I get an invalid old size error from…
I have a question about the realloc function. Will the content of old pointer be changed after apply realloc function?
The code is
main () {
int *a, *b, i;
a = calloc(5, sizeof(int));
for (i = 0; i < 5; i++)
a[i] = 1;
…
On line 56, I'm trying to resize an array:
tokenArray = (char**) realloc(tokenArray, tokSize * (sizeof(char)));
I get an error:
(11972,0x7fff7ca4f300) malloc: * error for object 0x100105598: incorrect checksum for freed object - object was…
The goal of my program is to read a file, and output the word with the max appearances, as well as the number of appearances. But I'm having issues with malloc and the syntax of it.
This is the structure which malloc refers to:
struct Word_setup {
…
Assuming that I have allocated memory using malloc(), if I do in my code:
char *newline = realloc ( oldline , newsize );
// Assuming oldline is the pointer to which the starting address
// of the memory which malloc() has returned, is assigned…
My code:
int args_size = 5;
char** args;
args = (char**) malloc(sizeof(char*) * args_size);
// ...
args = (char**) realloc(args, sizeof(char*) * (args_size += 5));
I want to increase the size by 5.
But I get this error:
*** glibc detected ***…
Possible Duplicate:
Realloc is not resizing array of pointers
Can anyone tell me where my mistake is? this function should make an array of the characters supplied from stdin. I read some related questions but it was too complicated for me to…
Disclaimer: This is homework. I am attempting it and do not expect or want anyone to do it for me. Just a few pointers (hehe) where I'm going wrong would be appreciated.
The homework requires me to create an int* array that holds 10 elements, and…
If the area pointed to was moved, a
free(ptr) is done.
Can you please explain the above line about realloc()? This line is from a man page for calloc, malloc, realloc and free.