mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
embedding: cef_string_map_append()
This commit is contained in:
parent
e486fa52d5
commit
7199c6ea58
1 changed files with 20 additions and 0 deletions
|
@ -34,3 +34,23 @@ pub extern "C" fn cef_string_map_size(sm: *mut cef_string_map_t) -> c_int {
|
|||
(*v).len() as c_int
|
||||
}
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn cef_string_map_append(sm: *mut cef_string_map_t, key: *const cef_string_t, value: *const cef_string_t) -> c_int {
|
||||
unsafe {
|
||||
if fptr_is_null(mem::transmute(sm)) { return 0; }
|
||||
let v = string_map_to_treemap(sm);
|
||||
slice::raw::buf_as_slice(mem::transmute((*key).str), (*key).length as uint, |result| {
|
||||
match str::from_utf8(result) {
|
||||
Some(k) => {
|
||||
let s = String::from_str(k);
|
||||
let csv = cef_string_userfree_utf8_alloc();
|
||||
cef_string_utf8_set(mem::transmute((*value).str), (*value).length, csv, 1);
|
||||
(*v).insert(s, csv);
|
||||
1
|
||||
},
|
||||
None => 0
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue