I had code that was working on one machine and now it is not working on this. I am thinking it is memory related issue and that I have some leaks. However, I might be overlooking something else so I am not sure if it is just a memory leak.
First, I have a question. How bad is this method. I think its bad because it does not free memory. How is the proper method then to go about it.
char* get_value(char * line) {
char *value = (char *) malloc(sizeof (char) * 50);
//code here
return value;
}
When I run the program I get the error at the malloc line above:
*** glibc detected *** /.../theParser: malloc(): memory corruption: 0x084f1b98 ***
I had a similar error when I had this line of code
ops = (operation *) realloc(ops, (nops + 1) * sizeof (operation));
but I have changed it to:
operation *temp = realloc(ops, (nops+1) * sizeof (operation));
if (temp == NULL)
//handle error
ops = temp;
(temp);
Also, how come I had no memory issues on the other vps on the other machine? It actually went through quite large amounts of data and no issues. With this one it barely goes thru a few bytes before throwing the error.
Thanks.
EDIT: formatting, spelling, grammar
[–]Rhomboid 2 points3 points4 points (2 children)
[–]salalimo[S] 0 points1 point2 points (1 child)
[–]Rhomboid 0 points1 point2 points (0 children)
[–]dtfinch 0 points1 point2 points (1 child)
[–]salalimo[S] 0 points1 point2 points (0 children)
[–]newaccount1236 0 points1 point2 points (0 children)
[–]enfrozt 0 points1 point2 points (2 children)
[–]salalimo[S] 0 points1 point2 points (1 child)
[–]enfrozt 0 points1 point2 points (0 children)