LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

ListGetItem question (from toolbox.h)

Hello all,
If I get an element pointer from a list with ListGetItem(), can I assume
that it stays valid while I keep inserting/deleting _other_ elements to the
list ?
Thanks
--
Guillaume Dargaud
http://www.gdargaud.net/
0 Kudos
Message 1 of 5
(2,907 Views)
Well, it looks like I misunderstood. I thought ListGetItem() returned a
pointer to the inside of the list, when it's just a copy. So that won't
work.
I need to keep pointers to some elements of my list, even while the list is
being manipulated. Suggestions unless I reimplement it myself ?
--
Guillaume Dargaud
http://www.gdargaud.net/
0 Kudos
Message 2 of 5
(2,906 Views)

I would think that ListGetPtrToItem or ListGetDataPtr would address your problem, but the documentation clearly states that they are only valid until the list is modified, so they won't survive list manipulation. Moreover, the documentation for the latter states that "items are stored (in memory) contiguously in ascending order": it appears that manipulating the list alters this order so that getting a valid pointer is not possible unless you perform a new list search.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 3 of 5
(2,900 Views)
> I would think that ListGetPtrToItem or ListGetDataPtr would address
> your problem, but the documentation clearly states that they are only
> valid until the list is modified, so they won't survive list manipulation.
> Moreover, the documentation for the latter states that "items are stored
> (in memory) contiguously in ascending order": it appears that manipulating
> the list alters this order so that getting a valid pointer is not possible
> unless you perform a new list search.

Yup. I decided to use the List* functions, but more intelligently: calling
when needed instead of using pointers.

Those functions are really handy. It's too bad that a lot of my code is not
in CVI but just standard C. I wish there were list functions in standard C.
Or source code from NI to recompile at willl... 😉
--
Guillaume Dargaud
http://www.gdargaud.net/
0 Kudos
Message 4 of 5
(2,877 Views)

Guillaume Dargaud ha scritto:

Those functions are really handy. It's too bad that a lot of my code is not
in CVI but just standard C. I wish there were list functions in standard C.
Or source code from NI to recompile at willl... 😉
--
Guillaume Dargaud
http://www.gdargaud.net/


Code for toolbox instrument is available in <cvidir>\toolslib\toolbox: don't know if it is possible to recompile all or part of it for use under Linux OS.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 5 of 5
(2,874 Views)