I am completely lost on why memcpy or memmove is not working for me.
I am trying to copy a array of struct (joblist) to another array of same struct (Q) to use for data manipulation, while keeping my original array intact.
I have spent a lot of time on SO and google troubleshooting this and I cannot find out why it won't work.
Q = new AdjacencyList[numjobs + 1]; //create a queue
// Q = joblist;
memmove(&Q, &joblist, sizeof(AdjacencyList) );
Q[0].jobnum = 30;
I tried to just make Q = joblist, but then when I changed a value in one, it changed in both.
struct AdjacencyList {
NodeType state; // what is present state of job?
NodePath path; // is job part of critical path?
int jobnum;
int edges;
int tocount;
int fromcount;
int to[50];
int from[50];
};
AdjacencyList *joblist;
AdjacencyList *Q;
This is the struct I created.
*** Error in `p5.out': corrupted double-linked list: 0x0989e8c0 ***
======= Backtrace: =========
/lib/libc.so.6[0x47975143]
/lib/libc.so.6[0x4797b984]
/lib/libc.so.6[0x4797cd28]
/lib/libstdc++.so.6(_ZdlPv+0x20)[0x47d8d9e0]
/lib/libstdc++.so.6(_ZdaPv+0x1c)[0x47d8da3c]
Any help would be greatly appreciated. Thanks.
SUB