summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2014-08-02 14:39:02 -0700
committerJohn Firebaugh <john.firebaugh@gmail.com>2014-08-02 14:39:42 -0700
commit992815cc3da3a440dbc56c61925a4e5443b58073 (patch)
tree37be5c36e377be959ffbe06450f90e44af1c9b49 /include
parent5f208c268b28d93027d9178ac4642a7b269db380 (diff)
downloadqtlocation-mapboxgl-992815cc3da3a440dbc56c61925a4e5443b58073.tar.gz
Avoid libuv resource leaks (fixes #395)
Diffstat (limited to 'include')
-rw-r--r--include/mbgl/util/uv.hpp13
1 files changed, 9 insertions, 4 deletions
diff --git a/include/mbgl/util/uv.hpp b/include/mbgl/util/uv.hpp
index f36da83e4d..a11d9b19cf 100644
--- a/include/mbgl/util/uv.hpp
+++ b/include/mbgl/util/uv.hpp
@@ -21,13 +21,18 @@ namespace uv {
class loop {
public:
- inline loop() : l(uv_loop_new()) {}
- inline ~loop() { uv_loop_delete(l); }
+ inline loop() {
+ if (uv_loop_init(&l) != 0) {
+ throw std::runtime_error("failed to initialize loop");
+ }
+ }
+
+ inline ~loop() { uv_loop_close(&l); }
- inline uv_loop_t *operator*() { return l; }
+ inline uv_loop_t *operator*() { return &l; }
private:
- uv_loop_t *l;
+ uv_loop_t l;
};
class mutex {