diff --git a/netsurfcss.rc b/netsurfcss.rc index cc705f4..a15ccc5 100644 --- a/netsurfcss.rc +++ b/netsurfcss.rc @@ -50,12 +50,12 @@ pub fn require_ok(code: css_error, what: &str) { } } -pub extern fn realloc(ptr: *c_void, len: size_t, _pw: *c_void) -> *c_void { +pub extern fn realloc(ptr: *mut c_void, len: size_t, _pw: *c_void) -> *mut c_void { unsafe { if len == 0 { // Needed to prevent a memory leak on Mac. - libc::free(ptr); - ptr::null() + libc::free(&*ptr); + ptr::mut_null() } else { libc::realloc(ptr, len) } @@ -228,7 +228,7 @@ pub mod stylesheet { } impl Drop for CssStylesheet { - fn finalize(&self) { + fn drop(&self) { assert!(self.sheet.is_not_null()); let code = unsafe { css_stylesheet_destroy(self.sheet) }; require_ok(code, "destroying stylesheet"); @@ -619,7 +619,7 @@ pub mod select { } impl Drop for CssSelectCtx { - fn finalize(&self) { + fn drop(&self) { assert!(self.select_ctx.is_not_null()); let code = unsafe { css_select_ctx_destroy(self.select_ctx) }; require_ok(code, "destroying select ctx"); @@ -1072,7 +1072,7 @@ pub mod select { } impl Drop for CssSelectResults { - fn finalize(&self) { + fn drop(&self) { assert!(self.results.is_not_null()); let code = unsafe { css_select_results_destroy(self.results) }; require_ok(code, "destroying select results"); diff --git a/util.rs b/util.rs index 7f98c78..3eab7af 100644 --- a/util.rs +++ b/util.rs @@ -13,13 +13,13 @@ use std::libc::c_void; use lwcstr_from_rust_str = wapcaplet::from_rust_string; pub fn css_fixed_to_float(f: css_fixed) -> float { - static before: i32 = 10; - f as float * 1.0f / ((1i32 << before) as float) + static BEFORE: i32 = 10; + f as float * 1.0f / ((1i32 << BEFORE) as float) } pub fn float_to_css_fixed(f: float) -> css_fixed { - static before: i32 = 10; - (f * ((1 << before) as float)) as css_fixed + static BEFORE: i32 = 10; + (f * ((1 << BEFORE) as float)) as css_fixed } pub fn rust_str_to_net_qname(s: &str) -> CssQName {