Skip to content

Commit

Permalink
Merge pull request yallop#563 from mseri/string-len
Browse files Browse the repository at this point in the history
CArray: add the null terminator in of_string
  • Loading branch information
yallop committed Apr 6, 2018
2 parents db21a8c + 26d49f8 commit a5aacb5
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/ctypes/ctypes_memory.ml
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,10 @@ struct
let element_type { astart } = reference_type astart

let of_string string =
let arr = make char (String.length string) in
let len = String.length string in
let arr = make char (len + 1) in
String.iteri (set arr) string;
set arr len '\x00';
arr

let of_list typ list =
Expand Down

0 comments on commit a5aacb5

Please sign in to comment.