+
+ /// <summary>
+ /// Converts a Char ** array of characters from the RRDLib returned as an IntPtr and converts
+ /// it to a String array given the number of items in the ptr array.
+ /// Re: http://stackoverflow.com/questions/1498931/marshalling-array-of-strings-to-char-in-c-must-be-quite-easy-if-you-know-ho
+ /// </summary>
+ /// <param name="ptr">Pointer to a character array returned from the RRDLib</param>
+ /// <param name="size">Number of items in the character array (not the number of characters)</param>
+ /// <returns>A string array</returns>
+ private static string[] GetStringArray(IntPtr ptr, UInt32 size)
+ {
+ var list = new List<string>();
+ for (int i = 0; i < size; i++)
+ {
+ var strPtr = (IntPtr)Marshal.PtrToStructure(ptr, typeof(IntPtr));
+ list.Add(Marshal.PtrToStringAnsi(strPtr));
+ ptr = new IntPtr(ptr.ToInt64() + IntPtr.Size);
+ }
+ return list.ToArray();
+ }