On Thu, Nov 21, 2013 at 11:07:21PM -0600, Maurice LeBrun wrote: > On Thursday, November 21, 2013 at 22:53:02 (-0600) Maurice LeBrun writes: > > I became curious reading this thread so I had a look -- apparently the > answer > > is in the code. From src/plcore.c: > > > > ... > > void > > plgDevs( const char ***p_menustr, const char ***p_devname, int *p_ndev ) > > { > > plgdevlst( *p_menustr, *p_devname, p_ndev, -1 ); > > } > > > > static void > > plgdevlst( const char **p_menustr, const char **p_devname, int *p_ndev, > int type ) > > { > > ... > > > > The pointers are dereferenced by the API calls to the implementing > routine, so > > are not needed. I probably meant to go back & fix that up eventually but > > ended up forgetting all about it. :) > > I should add, I think I initially saw the problem as Andrew put it, that the > array of char*'s was like a 2d array so in order to "return" it I needed to > pass a pointer to a 2d array i.e. char***. But then realized I could skip > that and just do pointer copies instead. Bleah.. give me a nice class foo& > any day..
Maurice is right. We could make this simpler. The function is not part of the common API so we could make a change now, although the function has been available in C for quite a while so this may cause backwards incompatibilities for some users. With regard to the "const", this just means that the values won't be modified, which is true since the function just returns an array of pointers to the const device strings. This provides (some) safety to prevent the user trying to modify them. They would need an explicit cast to lose the const. This is my interpretation anyway. The use of const with char arrays is complicated and one of those things I always need to go away and check. Andrew ------------------------------------------------------------------------------ Shape the Mobile Experience: Free Subscription Software experts and developers: Be at the forefront of tech innovation. Intel(R) Software Adrenaline delivers strategic insight and game-changing conversations that shape the rapidly evolving mobile landscape. Sign up now. http://pubads.g.doubleclick.net/gampad/clk?id=63431311&iu=/4140/ostg.clktrk _______________________________________________ Plplot-devel mailing list Plplot-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/plplot-devel