01-11-2007 12:05 AM
01-11-2007 01:41 AM
01-11-2007 02:12 AM
Hello Roberto
Thanks for you promote reply first.
actually i used this command in background printing tasking. i want to copy the test struct array to a temp buff to avoid two threading access same buffer on same time, so i need allocate a buff that same as test struct array. in otherword, this command work well in another C file which in my project also. i try to copy this command to that C file , it's work propery (any place). Indeed , i tried so clear to compare the include .h file in both C file. no so much difference.
I am a little bit headache on this. 😞
Gerry Li
01-11-2007 08:03 AM
Hello Gerry,
I definitely confirm that calloc receives the number of elements in the first parameters and the size of each element in the second. This is practically equivalent to your notation since what is effectively allocated is a space of numOfElements * sizeOfElement bytes but can conceptually lead to some misunderstanding.
Given this, I don't know why you are seeing one single element only, unless it is only a problem of CVI variable window settings. Try this: break in the program and view p_testDB variable in the variables window; be sure the structure is in compressed format (the "+" icon shown on the left and no element shown) and execute Options >> Interpret as... menu function: select in the list the type struct testDB * instead of struct testDB that is probably selected; press OK and expand again your variable: now it should correctly show your 10 elements array of structures.
01-11-2007 08:25 PM
Hello Roberto
Yes, you are right, follow the instruction of calloc function. the first parameter should be num of element. but i do not know. why this fucntion work will in my project after i exchanging the parameter. i copy the screen and put in the attached file.for you reference.
for my problem, i am sorry to tell you that , still not fixed. I use the function in option menu to get the number of element , only 1. see attachemnt for detail.
Thanks
Gerry Li
01-11-2007 08:31 PM
Hello Roberto
I can not put the attachment to BBS. can you tell me you mailing address?
01-12-2007 08:17 AM
01-13-2007 05:02 AM
@ Al - as we can see in the variable window posted, the reassignment is not already performed at the breakpoint: address of p_TestDB is 10k higher than that of ThisPtr. Nevertheless, this will be a problem in further execution of the program since he wants to have a copy of memory structure while he is actually simply reassigning the memory block pointer.
@ Gerry - I see in the variable window that p_testDB is assigned PtrTestDB type. Can you reassign it to ptrTestDB * type instead?
In any case, look at my profile for my e-mail address.
01-15-2007 08:22 PM
Hello Roberto
I tried according to you suggestion. no any effort. also i try to define a struct in print.c file and result looks same. So i do not think this is a problem in my struct defination. i send you this one , you may able to find some some details.
Thanks
Gerry Li
01-16-2007 02:06 AM
Gerry, I see no evident reason for the behaviour you are observing: integrating your code in a program of mine leads to a correct definition of an array of structures.
Regardless the Variable window aspect, can you access individual array elements (e.g. assigning p1[1].a = 12; ) Or, have you tried using Options >> Estimate number of elements menu function?