Skip to content

Instantly share code, notes, and snippets.

@springmeyer
Created May 16, 2014 22:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save springmeyer/51e39e5a78c603824c35 to your computer and use it in GitHub Desktop.
Save springmeyer/51e39e5a78c603824c35 to your computer and use it in GitHub Desktop.
atexit OGRCleanupAll() and GDALDestroyDriverManager()
diff --git a/plugins/input/gdal/gdal_datasource.cpp b/plugins/input/gdal/gdal_datasource.cpp
index 78ca37a..866057e 100644
--- a/plugins/input/gdal/gdal_datasource.cpp
+++ b/plugins/input/gdal/gdal_datasource.cpp
@@ -44,7 +44,13 @@ using mapnik::featureset_ptr;
using mapnik::layer_descriptor;
using mapnik::datasource_exception;
+void atexit_handler_1()
+{
+ std::cout << "at exit #1\n";
+ GDALDestroyDriverManager();
+}
+const int result_1 = std::atexit(atexit_handler_1)
/*
* Opens a GDALDataset and returns a pointer to it.
* Caller is responsible for calling GDALClose on it
diff --git a/plugins/input/ogr/ogr_datasource.cpp b/plugins/input/ogr/ogr_datasource.cpp
index 5269c96..f001f68 100644
--- a/plugins/input/ogr/ogr_datasource.cpp
+++ b/plugins/input/ogr/ogr_datasource.cpp
@@ -23,7 +23,7 @@
#include "ogr_datasource.hpp"
#include "ogr_featureset.hpp"
#include "ogr_index_featureset.hpp"
-
+#include <ogr_api.h>
#include <gdal_version.h>
// mapnik
@@ -57,6 +57,14 @@ using mapnik::datasource_exception;
using mapnik::filter_in_box;
using mapnik::filter_at_point;
+void atexit_handler_2()
+{
+ std::cout << "at exit #2\n";
+ OGRCleanupAll();
+}
+
+const int result_2 = std::atexit(atexit_handler_2);
+
ogr_datasource::ogr_datasource(parameters const& params)
: datasource(params),
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment