Category : dynamic-memory-allocation

I’m trying to write a class in c++ that creates a dynamic array and I’m encountering this problem malloc: Incorrect checksum for freed object 0x7f9ff3c05aa8: probably modified after being freed. Corrupt value: 0x2000000000000 I implemented three constructors (default, parametrized and copy) and I think this is the one causing problem because the code breaks here ..

Read more

I have two arrays, y_train which is 1D array and x_train which is 2D array. I need to dynamically allocated these two arrays using posix_memalign. I did that for y_train correctly. where I convert int y_train[4344] into the folloing code. int* Y_train; posix_memalign((void**)(&Y_train), 64, sizeof(int) * 4344); Now, I want to convert int x_train[4344][20]; in ..

Read more

I’m having trouble manipulating a doubly linked list. I’m pretty sure I have my addNode(), getCount(), printList(), and getNode() working fine, but when executing, I get to right around my exists() and deleteNode() methods and I get a segmentation fault. exists() checks to see if a specific node exists, and deleteNode() passes in an id, ..

Read more