> On May 24, 2021, at 9:36 PM, Nick Rosbrook <rosbro...@gmail.com> wrote: > > The current implementation of StringList.toC does not correctly account > for how libxl_string_list is expected to be laid out in C, which is clear > when one looks at libxl_string_list_length in libxl.c. In particular, > StringList.toC does not account for the extra memory that should be > allocated for the "sentinel" entry. And, when using the "slice trick" to > create a slice that can address C memory, the unsafe.Pointer conversion > should be on a C.libxl_string_list, not *C.libxl_string_list. > > Fix these problems by (1) allocating an extra slot in the slice used to > address the C memory, and explicity set the last entry to nil so the C > memory will be zeroed out, and (2) dereferencing csl in the > unsafe.Pointer conversion. > > Signed-off-by: Nick Rosbrook <rosbro...@ainfosec.com> Reviewed-by: George Dunlap <george.dun...@citrix.com> Even as I was making these I thought it might be good to try to get some unit tests of this conversion.
- [RESEND PATCH 00/12] golang/xenlight: domain life cycle supp... Nick Rosbrook
- [RESEND PATCH 01/12] golang/xenlight: update generated ... Nick Rosbrook
- Re: [RESEND PATCH 01/12] golang/xenlight: update ge... George Dunlap
- [RESEND PATCH 02/12] golang/xenlight: fix StringList to... Nick Rosbrook
- Re: [RESEND PATCH 02/12] golang/xenlight: fix Strin... George Dunlap
- [RESEND PATCH 03/12] golang/xenlight: fix string conver... Nick Rosbrook
- Re: [RESEND PATCH 03/12] golang/xenlight: fix strin... George Dunlap
- Re: [RESEND PATCH 03/12] golang/xenlight: fix s... Nick Rosbrook
- Re: [RESEND PATCH 03/12] golang/xenlight: f... George Dunlap
- Re: [RESEND PATCH 03/12] golang/xenlig... Nick Rosbrook
- [RESEND PATCH 04/12] golang/xenlight: export keyed unio... Nick Rosbrook
- Re: [RESEND PATCH 04/12] golang/xenlight: export ke... George Dunlap
- [RESEND PATCH 05/12] golang/xenlight: use struct pointe... Nick Rosbrook
- Re: [RESEND PATCH 05/12] golang/xenlight: use struc... George Dunlap
- [RESEND PATCH 06/12] golang/xenlight: rename Ctx receiv... Nick Rosbrook