I have a class I am creating that is a template for a fixed-size linked list (basically an array of nodes with room for whatever kind of object is going in, a Next pointer, and an InUse flag.)
My problem is that when I try to "get" the data from a node, the system throws up an exception. Running the debugger, I can see that I have copied the object into the memory space and it is correct as far as I can tell. The "GetData" operation from the node should return a pointer to its object. (The object usually has a GetData function, as well, since the object is usually a class to hold the object that will fit the template to go into the list.)
The main program (fragment) with assembly code is here:
732: mytestclassOll->FindObject3(0)->GetData()->GetData();
00412A09 push 0
00412A0B mov ecx,dword ptr [ebp-3Ch]
00412A0E call @ILT+1380(C_ordered_linked_list_fixed_size<testclass>::FindObject3) (00401569)
00412A13 mov dword ptr [ebp-0DCh],eax
00412A19 mov edx,dword ptr [ebp-0DCh]
00412A1F mov eax,dword ptr [edx]
00412A21 mov esi,esp
00412A23 mov ecx,dword ptr [ebp-0DCh]
00412A29 call dword ptr [eax+4]
The last line is where the exception occurred (access violation). I do not know how to translate this assembly very well.
The code for GetData (of the node) looks like this:
template <class T>
T* C_ordered_linked_list_fixed_size_internal_node<T>::GetData()
{
return &myObject;
}
and the SetObject operation (where I copy the object into the node) looks like this:
template <class T>
C_ordered_linked_list_fixed_size_internal_node<T>::SetObject(T* theObject)
{
myObject = *theObject;
InUse = TRUE;
}
Sorry for writing a novel. Any insights are greatly appreciated!
My problem is that when I try to "get" the data from a node, the system throws up an exception. Running the debugger, I can see that I have copied the object into the memory space and it is correct as far as I can tell. The "GetData" operation from the node should return a pointer to its object. (The object usually has a GetData function, as well, since the object is usually a class to hold the object that will fit the template to go into the list.)
The main program (fragment) with assembly code is here:
732: mytestclassOll->FindObject3(0)->GetData()->GetData();
00412A09 push 0
00412A0B mov ecx,dword ptr [ebp-3Ch]
00412A0E call @ILT+1380(C_ordered_linked_list_fixed_size<testclass>::FindObject3) (00401569)
00412A13 mov dword ptr [ebp-0DCh],eax
00412A19 mov edx,dword ptr [ebp-0DCh]
00412A1F mov eax,dword ptr [edx]
00412A21 mov esi,esp
00412A23 mov ecx,dword ptr [ebp-0DCh]
00412A29 call dword ptr [eax+4]
The last line is where the exception occurred (access violation). I do not know how to translate this assembly very well.
The code for GetData (of the node) looks like this:
template <class T>
T* C_ordered_linked_list_fixed_size_internal_node<T>::GetData()
{
return &myObject;
}
and the SetObject operation (where I copy the object into the node) looks like this:
template <class T>
C_ordered_linked_list_fixed_size_internal_node<T>::SetObject(T* theObject)
{
myObject = *theObject;
InUse = TRUE;
}
Sorry for writing a novel. Any insights are greatly appreciated!