{"action":"opened","issue":{"url":"https://api.github.com/repos/ros2/rcl/issues/77","repository_url":"https://api.github.com/repos/ros2/rcl","labels_url":"https://api.github.com/repos/ros2/rcl/issues/77/labels{/name}","comments_url":"https://api.github.com/repos/ros2/rcl/issues/77/comments","events_url":"https://api.github.com/repos/ros2/rcl/issues/77/events","html_url":"https://github.com/ros2/rcl/issues/77","id":173227284,"number":77,"title":"rcl/rosidl arrays - need some help understanding","user":{"login":"firesurfer","id":8481806,"avatar_url":"https://avatars.githubusercontent.com/u/8481806?v=3","gravatar_id":"","url":"https://api.github.com/users/firesurfer","html_url":"https://github.com/firesurfer","followers_url":"https://api.github.com/users/firesurfer/followers","following_url":"https://api.github.com/users/firesurfer/following{/other_user}","gists_url":"https://api.github.com/users/firesurfer/gists{/gist_id}","starred_url":"https://api.github.com/users/firesurfer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/firesurfer/subscriptions","organizations_url":"https://api.github.com/users/firesurfer/orgs","repos_url":"https://api.github.com/users/firesurfer/repos","events_url":"https://api.github.com/users/firesurfer/events{/privacy}","received_events_url":"https://api.github.com/users/firesurfer/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-08-25T14:59:43Z","updated_at":"2016-08-25T14:59:43Z","closed_at":null,"body":"I'm currently trying to implement arrays in my .net wrapper. At the moment I'm running into some problems. Let's take an int8 array for example:\r\n\r\nOn C side the struct for the array contains three entries:\r\n```\r\ntypedef struct rosidl_generator_c__int8__Array\r\n{\r\n    int8* data;\r\n    size_t size;\r\n    size_t capacity;\r\n}rosidl_generator_c__int8__Array;\r\n```\r\n\r\nAs far as I understand the initialization code for the arrays I have to insert a pointer into the data field, and insert the amount of array elements into the size field. The capacity field is the same value as the size field. Is this correct?\r\n\r\n@esteve Are there any other traps you could imagine when passing arrays from .net to native code that invoke this error?\r\n\r\n> terminate called after throwing an instance of 'eprosima::fastcdr::exception::NotEnoughMemoryException'\r\n  what():  Not enough memory in the buffer stream\r\n\r\nAt the moment I',m doing the marshalling by hand: For example for the int8 array:\r\n```\r\n[StructLayout(LayoutKind.Sequential)]\r\n\tpublic struct rosidl_generator_c__primitive_array_int8\r\n\t{\t\r\n\t\tpublic IntPtr Data ;\r\n\t\tUIntPtr Size;\r\n\t\tUIntPtr Capacity;\r\n\r\n\r\n\t\tpublic rosidl_generator_c__primitive_array_int8(byte[] _Data)\r\n\t\t{\r\n\t\t\t\r\n\t\t\tData = Marshal.AllocHGlobal (_Data.Length);//Marshal.SizeOf<byte> ()*_Data.Length);\r\n\t\t\tSize = (UIntPtr) _Data.Length;\r\n\t\t\tCapacity = Size;\r\n\t\t\tMarshal.Copy (_Data, 0, Data, _Data.Length);\r\n\t\t}\r\n\t\tpublic byte[] Array\r\n\t\t{\r\n\t\t\tget{ byte[] tempArray = new byte[(int)Size]; \r\n\t\t\t\tMarshal.Copy (Data, tempArray, 0, (int)Size);\r\n\t\t\t\treturn tempArray;}\r\n\t\t}\r\n\t\tpublic int ArraySize\r\n\t\t{\r\n\t\t\tget{return (int)Size;}\r\n\t\t}\r\n\t\tpublic int ArrayCapacity\r\n\t\t{\r\n\t\t\tget{ return (int)Capacity;}\r\n\t\t}\r\n\t}\r\n```\r\n"}}
{"actor":{"display_login":"firesurfer"}}