Skip to content

Commit 5871f58

Browse files
committed
Document the string_to_malloc_ptr() function
1 parent b83ff67 commit 5871f58

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,9 @@ pub extern fn dummy_callback(request: *mut ZabbixRequest, result: *mut ZabbixRes
195195
SYSINFO_RET_OK
196196
}
197197

198+
// When the result of a Zabbix item is text (string, text and message)
199+
// Zabbix expects to receive a pre-allocated pointer with the result
200+
// string, which is free(3)'d by Zabbix once done with the result.
198201
unsafe fn string_to_malloc_ptr(src: &str) -> *mut c_char {
199202
let c_src = ffi::CString::new(src).unwrap();
200203
let len = c_src.to_bytes_with_nul().len() as u64;

0 commit comments

Comments
 (0)