From: Jared_B on
Lawrence, Is the DLL or LabVIEW throwing the malloc error?Have you turned on maximum error checking with your CLFN?Assuming your malloc for 0x20000 is your 128k, are you able to increase this 1.5 or 2 times?In your DLL when are you destroying your memory allocation?Lastly, I am curious as to why you are needing to allocate memory with the pointer - shouldn't the pointer already be referencing something pre-loaded into memory?
From: lmd2 on
sorry, let me elaborate; the client has requested the driver by in LabVIEW 7.0 so error checking is minimalthe problem is that I don't know the LabVIEW version of malloc, memory allocation is done dynamically in the background, so how would I increase it by 1.5 or 2X?the allocation is for a buffer which is filled if messages are present on the busthanxlmd2
From: rolfk on
lmd2 wrote:sorry, let me elaborate; the client has requested the driver by in LabVIEW 7.0 so error checking is minimalthe problem is that I don't know the LabVIEW version of malloc, memory allocation is done dynamically in the background, so how would I increase it by 1.5 or 2X?the allocation is for a buffer which is filled if messages are present on the busthanxlmd2When you create an array or string or any variable on a diagram LabVIEW is behind the scenes mallocing the memory for you automaticially and when you pass such a wire to the Call Library Node it's memory address is passed to the DLL according to that parameter configuration. So unless your C function does want to resize, deallocate or otherwise change that memory pointer itself there is no need to know about what malloc was used.Your problem is a different one I guess. While the parameter looks like a pointer to a structure it is apparently a pointer to an array of structures. In C these two things are exactly the same as far as the compiler is concerned. It is only the context of the function and it's callers that determine if it is one or the other.Now the problem is that you cannot pass an array of clusters to a DLL function directly since the necessary translation of that could get rather complicated and it's configuration would cause the Call Library Node Dialog to get complicated beyond anyones imagination and consequently beyond most peoples comprehension and usability.So if you need to do this all in LabVIEW instead of writing a wrapper DLL you will have to allocate an array of Bytes instead with the Initialize Array function and pass that like that to the DLL function. On return and if you would be in LabVIEW 8.2 and better you might be able to Unflatten the Array of Bytes into an Array of Clusters if this cluster does not contain any arrays or strings and specify to use Little Endian format and data includes array or string size = False.However LabVIEW 7 does not have such a versatile Unflatten. You might be able to use Typecast instead but will have to pass the resulting array of cluster wire through the swap bytes and swap words function too in order to compensate for the Big Endian standardization that is done by the Typecast function.Rolf Kalbermatter
From: lmd2 on
Thank you this sounds correct, although implementing it is going to take a bit of doing (actually the cluster does contain two arrays of U16, but no strings (arrays of U8)). Normally I can handle an array within a cluster by converting it to a cluster within a cluster - but in this case, this will make it more difficult to do a type cast.But you have given me some insight and a direction -thanx again, lmd2
From: rolfk on
lmd2 wrote:Thank youthis sounds correct, although implementing it is going to take a bit of doing (actually the cluster does contain two arrays of U16, but no strings (arrays of U8)). Normally I can handle an array within a cluster by converting it to a cluster within a cluster - but in this case, this will make it more difficult to do a type cast.But you have given me some insight and a direction -thanx again, lmd2Well it all depends on if this array is fixed size (unsigned short name[x]) or if it is just a pointer (unsigned short *name). In the first case the C compiler inlines the array and you can indeed treat it as an embedded cluster of the right (x) amount of elements, but in the second case you have to treat it as an uInt32 (uInt64 on the upcoming LabVIEW for Windows x64 platform) and do some other magic if you need to retrieve the values.Inlined clusters in a cluster are no problem for the Typecast function. Pointers treated as unsigned integer also not.Rolf KalbermatterMessage Edited by rolfk on 06-20-2008 11:08 AM
 |  Next  |  Last
Pages: 1 2 3 4 5 6 7 8 9 10
Prev: error 200279
Next: CMD.EXE Output Not Showing up