[librsvg] node.rs: Only drop the RsvgState if *not* in testing mode
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg] node.rs: Only drop the RsvgState if *not* in testing mode
- Date: Thu, 16 Mar 2017 05:16:05 +0000 (UTC)
commit d44b0ec3765f7aa5080edfd5f8e3b1296a278fa7
Author: Federico Mena Quintero <federico gnome org>
Date: Fri Mar 3 14:14:24 2017 -0600
node.rs: Only drop the RsvgState if *not* in testing mode
We don't have rsvg_state_free() available if we are linking in testing
mode. Conditionally compile the Drop trait then; there are no leaks
because in testing mode we don't create RsvgState objects anyway.
The effect of this commit is to actually free the states in release mode!
rust/src/node.rs | 16 ++++++++++------
1 files changed, 10 insertions(+), 6 deletions(-)
---
diff --git a/rust/src/node.rs b/rust/src/node.rs
index b8ed91f..557bc5b 100644
--- a/rust/src/node.rs
+++ b/rust/src/node.rs
@@ -232,13 +232,18 @@ impl Node {
}
}
-extern "C" {
- fn rsvg_state_free (state: *mut RsvgState);
-}
-
+// Sigh, rsvg_state_free() is only available if we are being linked into
+// librsvg.so. In testing mode, we run standalone, so we omit this.
+// Fortunately, in testing mode we don't create "real" nodes with
+// states; we only create stub nodes with ptr::null() for state.
+#[cfg(not(test))]
impl Drop for Node {
+
fn drop (&mut self) {
-// unsafe { rsvg_state_free (self.state); }
+ extern "C" {
+ fn rsvg_state_free (state: *mut RsvgState);
+ }
+ unsafe { rsvg_state_free (self.state); }
}
}
@@ -389,7 +394,6 @@ mod tests {
use drawing_ctx::RsvgDrawingCtx;
use handle::RsvgHandle;
use property_bag::RsvgPropertyBag;
- use state::RsvgState;
use super::*;
use std::ptr;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]