1. yotis
  2. glxx

Commits

yotis  committed 337f295

Fixed issue #2 (memleaking default_loaders)

  • Participants
  • Parent commits 2830b5a
  • Branches default

Comments (0)

Files changed (7)

File generator/glXxx.py

View file
  • Ignore whitespace
 #include <sstream>
 #include <iterator>
 #include <algorithm>
+#include <memory>
 
 namespace glXxx
 {

File generator/glxx.py

View file
  • Ignore whitespace
 #include <sstream>
 #include <vector>
 #include <algorithm>
+#include <memory>
 
 
 #ifdef __linux__

File generator/parse.py

View file
  • Ignore whitespace
             out_cpp.append(
 '        %s(0),' % fun.name)
             
-        out_cpp.append(
-'''        is_loaded(true)
+        out_cpp.append('''
+        is_loaded(true)
 {
     assert(GetCurrentCtx() && "%s_%s::Loader initialized without a current context");''' 
                 % (prefix.lower(), category.lower()))
 """ % (category.lower(), prefix.upper(), category))
         
         out_cpp.append("""
-%s_%s::Loader* default_%s_loader = 0;
+std::auto_ptr<%s_%s::Loader> default_%s_loader;
 
 bool load_%s() 
 {
-    if (default_%s_loader)
-        delete default_%s_loader;
-    default_%s_loader = new %s_%s::Loader();
+    default_%s_loader.reset(new %s_%s::Loader);
     return default_%s_loader->isLoaded();
 }
 """ % (prefix.lower(), category.lower(), category.lower(), 
        category.lower(),
-       category.lower(),
-       category.lower(),
-       category.lower(), prefix.lower(), category.lower(), 
+       category.lower(), prefix.lower(), category.lower(),
        category.lower()))
             
         for fun in category_functions:

File generator/wglxx.py

View file
  • Ignore whitespace
 #include <sstream>
 #include <vector>
 #include <algorithm>
+#include <memory>
 
 namespace wglxx 
 {

File glXxx.cpp

View file
  • Ignore whitespace
 #include <sstream>
 #include <iterator>
 #include <algorithm>
+#include <memory>
 
 namespace glXxx
 {
         QueryContext(0),
         SelectEvent(0),
         GetSelectedEvent(0),
+
         is_loaded(true)
 {
     assert(GetCurrentCtx() && "glx_version_1_3::Loader initialized without a current context");
 }
 
 
-glx_version_1_3::Loader* default_version_1_3_loader = 0;
+std::auto_ptr<glx_version_1_3::Loader> default_version_1_3_loader;
 
 bool load_version_1_3() 
 {
-    if (default_version_1_3_loader)
-        delete default_version_1_3_loader;
-    default_version_1_3_loader = new glx_version_1_3::Loader();
+    default_version_1_3_loader.reset(new glx_version_1_3::Loader);
     return default_version_1_3_loader->isLoaded();
 }
 
         SelectEvent(0),
         GetSelectedEvent(0),
         GetProcAddress(0),
+
         is_loaded(true)
 {
     assert(GetCurrentCtx() && "glx_version_1_4::Loader initialized without a current context");
 }
 
 
-glx_version_1_4::Loader* default_version_1_4_loader = 0;
+std::auto_ptr<glx_version_1_4::Loader> default_version_1_4_loader;
 
 bool load_version_1_4() 
 {
-    if (default_version_1_4_loader)
-        delete default_version_1_4_loader;
-    default_version_1_4_loader = new glx_version_1_4::Loader();
+    default_version_1_4_loader.reset(new glx_version_1_4::Loader);
     return default_version_1_4_loader->isLoaded();
 }
 
 
 glx_arb_get_proc_address::Loader::Loader() :
         GetProcAddressARB(0),
+
         is_loaded(true)
 {
     assert(GetCurrentCtx() && "glx_arb_get_proc_address::Loader initialized without a current context");
 }
 
 
-glx_arb_get_proc_address::Loader* default_arb_get_proc_address_loader = 0;
+std::auto_ptr<glx_arb_get_proc_address::Loader> default_arb_get_proc_address_loader;
 
 bool load_arb_get_proc_address() 
 {
-    if (default_arb_get_proc_address_loader)
-        delete default_arb_get_proc_address_loader;
-    default_arb_get_proc_address_loader = new glx_arb_get_proc_address::Loader();
+    default_arb_get_proc_address_loader.reset(new glx_arb_get_proc_address::Loader);
     return default_arb_get_proc_address_loader->isLoaded();
 }
 
 
 
 glx_arb_multisample::Loader::Loader() :
+
         is_loaded(true)
 {
     assert(GetCurrentCtx() && "glx_arb_multisample::Loader initialized without a current context");
 }
 
 
-glx_arb_multisample::Loader* default_arb_multisample_loader = 0;
+std::auto_ptr<glx_arb_multisample::Loader> default_arb_multisample_loader;
 
 bool load_arb_multisample() 
 {
-    if (default_arb_multisample_loader)
-        delete default_arb_multisample_loader;
-    default_arb_multisample_loader = new glx_arb_multisample::Loader();
+    default_arb_multisample_loader.reset(new glx_arb_multisample::Loader);
     return default_arb_multisample_loader->isLoaded();
 }
 
 
 
 glx_arb_fbconfig_float::Loader::Loader() :
+
         is_loaded(true)
 {
     assert(GetCurrentCtx() && "glx_arb_fbconfig_float::Loader initialized without a current context");
 }
 
 
-glx_arb_fbconfig_float::Loader* default_arb_fbconfig_float_loader = 0;
+std::auto_ptr<glx_arb_fbconfig_float::Loader> default_arb_fbconfig_float_loader;
 
 bool load_arb_fbconfig_float() 
 {
-    if (default_arb_fbconfig_float_loader)
-        delete default_arb_fbconfig_float_loader;
-    default_arb_fbconfig_float_loader = new glx_arb_fbconfig_float::Loader();
+    default_arb_fbconfig_float_loader.reset(new glx_arb_fbconfig_float::Loader);
     return default_arb_fbconfig_float_loader->isLoaded();
 }
 
 
 
 glx_arb_framebuffer_srgb::Loader::Loader() :
+
         is_loaded(true)
 {
     assert(GetCurrentCtx() && "glx_arb_framebuffer_srgb::Loader initialized without a current context");
 }
 
 
-glx_arb_framebuffer_srgb::Loader* default_arb_framebuffer_srgb_loader = 0;
+std::auto_ptr<glx_arb_framebuffer_srgb::Loader> default_arb_framebuffer_srgb_loader;
 
 bool load_arb_framebuffer_srgb() 
 {
-    if (default_arb_framebuffer_srgb_loader)
-        delete default_arb_framebuffer_srgb_loader;
-    default_arb_framebuffer_srgb_loader = new glx_arb_framebuffer_srgb::Loader();
+    default_arb_framebuffer_srgb_loader.reset(new glx_arb_framebuffer_srgb::Loader);
     return default_arb_framebuffer_srgb_loader->isLoaded();
 }
 
 
 glx_arb_create_context::Loader::Loader() :
         CreateContextAttribsARB(0),
+
         is_loaded(true)
 {
     assert(GetCurrentCtx() && "glx_arb_create_context::Loader initialized without a current context");
 }
 
 
-glx_arb_create_context::Loader* default_arb_create_context_loader = 0;
+std::auto_ptr<glx_arb_create_context::Loader> default_arb_create_context_loader;
 
 bool load_arb_create_context() 
 {
-    if (default_arb_create_context_loader)
-        delete default_arb_create_context_loader;
-    default_arb_create_context_loader = new glx_arb_create_context::Loader();
+    default_arb_create_context_loader.reset(new glx_arb_create_context::Loader);
     return default_arb_create_context_loader->isLoaded();
 }
 
 
 
 glx_arb_create_context_profile::Loader::Loader() :
+
         is_loaded(true)
 {
     assert(GetCurrentCtx() && "glx_arb_create_context_profile::Loader initialized without a current context");
 }
 
 
-glx_arb_create_context_profile::Loader* default_arb_create_context_profile_loader = 0;
+std::auto_ptr<glx_arb_create_context_profile::Loader> default_arb_create_context_profile_loader;
 
 bool load_arb_create_context_profile() 
 {
-    if (default_arb_create_context_profile_loader)
-        delete default_arb_create_context_profile_loader;
-    default_arb_create_context_profile_loader = new glx_arb_create_context_profile::Loader();
+    default_arb_create_context_profile_loader.reset(new glx_arb_create_context_profile::Loader);
     return default_arb_create_context_profile_loader->isLoaded();
 }
 
 
 
 glx_arb_create_context_robustness::Loader::Loader() :
+
         is_loaded(true)
 {
     assert(GetCurrentCtx() && "glx_arb_create_context_robustness::Loader initialized without a current context");
 }
 
 
-glx_arb_create_context_robustness::Loader* default_arb_create_context_robustness_loader = 0;
+std::auto_ptr<glx_arb_create_context_robustness::Loader> default_arb_create_context_robustness_loader;
 
 bool load_arb_create_context_robustness() 
 {
-    if (default_arb_create_context_robustness_loader)
-        delete default_arb_create_context_robustness_loader;
-    default_arb_create_context_robustness_loader = new glx_arb_create_context_robustness::Loader();
+    default_arb_create_context_robustness_loader.reset(new glx_arb_create_context_robustness::Loader);
     return default_arb_create_context_robustness_loader->isLoaded();
 }
 
 
 
 glx_sgis_multisample::Loader::Loader() :
+
         is_loaded(true)
 {
     assert(GetCurrentCtx() && "glx_sgis_multisample::Loader initialized without a current context");
 }
 
 
-glx_sgis_multisample::Loader* default_sgis_multisample_loader = 0;
+std::auto_ptr<glx_sgis_multisample::Loader> default_sgis_multisample_loader;
 
 bool load_sgis_multisample() 
 {
-    if (default_sgis_multisample_loader)
-        delete default_sgis_multisample_loader;
-    default_sgis_multisample_loader = new glx_sgis_multisample::Loader();
+    default_sgis_multisample_loader.reset(new glx_sgis_multisample::Loader);
     return default_sgis_multisample_loader->isLoaded();
 }
 
 
 
 glx_ext_visual_info::Loader::Loader() :
+
         is_loaded(true)
 {
     assert(GetCurrentCtx() && "glx_ext_visual_info::Loader initialized without a current context");
 }
 
 
-glx_ext_visual_info::Loader* default_ext_visual_info_loader = 0;
+std::auto_ptr<glx_ext_visual_info::Loader> default_ext_visual_info_loader;
 
 bool load_ext_visual_info() 
 {
-    if (default_ext_visual_info_loader)
-        delete default_ext_visual_info_loader;
-    default_ext_visual_info_loader = new glx_ext_visual_info::Loader();
+    default_ext_visual_info_loader.reset(new glx_ext_visual_info::Loader);
     return default_ext_visual_info_loader->isLoaded();
 }
 
 
 glx_sgi_swap_control::Loader::Loader() :
         SwapIntervalSGI(0),
+
         is_loaded(true)
 {
     assert(GetCurrentCtx() && "glx_sgi_swap_control::Loader initialized without a current context");
 }
 
 
-glx_sgi_swap_control::Loader* default_sgi_swap_control_loader = 0;
+std::auto_ptr<glx_sgi_swap_control::Loader> default_sgi_swap_control_loader;
 
 bool load_sgi_swap_control() 
 {
-    if (default_sgi_swap_control_loader)
-        delete default_sgi_swap_control_loader;
-    default_sgi_swap_control_loader = new glx_sgi_swap_control::Loader();
+    default_sgi_swap_control_loader.reset(new glx_sgi_swap_control::Loader);
     return default_sgi_swap_control_loader->isLoaded();
 }
 
 glx_sgi_video_sync::Loader::Loader() :
         GetVideoSyncSGI(0),
         WaitVideoSyncSGI(0),
+
         is_loaded(true)
 {
     assert(GetCurrentCtx() && "glx_sgi_video_sync::Loader initialized without a current context");
 }
 
 
-glx_sgi_video_sync::Loader* default_sgi_video_sync_loader = 0;
+std::auto_ptr<glx_sgi_video_sync::Loader> default_sgi_video_sync_loader;
 
 bool load_sgi_video_sync() 
 {
-    if (default_sgi_video_sync_loader)
-        delete default_sgi_video_sync_loader;
-    default_sgi_video_sync_loader = new glx_sgi_video_sync::Loader();
+    default_sgi_video_sync_loader.reset(new glx_sgi_video_sync::Loader);
     return default_sgi_video_sync_loader->isLoaded();
 }
 
 glx_sgi_make_current_read::Loader::Loader() :
         MakeCurrentReadSGI(0),
         GetCurrentReadDrawableSGI(0),
+
         is_loaded(true)
 {
     assert(GetCurrentCtx() && "glx_sgi_make_current_read::Loader initialized without a current context");
 }
 
 
-glx_sgi_make_current_read::Loader* default_sgi_make_current_read_loader = 0;
+std::auto_ptr<glx_sgi_make_current_read::Loader> default_sgi_make_current_read_loader;
 
 bool load_sgi_make_current_read() 
 {
-    if (default_sgi_make_current_read_loader)
-        delete default_sgi_make_current_read_loader;
-    default_sgi_make_current_read_loader = new glx_sgi_make_current_read::Loader();
+    default_sgi_make_current_read_loader.reset(new glx_sgi_make_current_read::Loader);
     return default_sgi_make_current_read_loader->isLoaded();
 }
 
 glx_sgix_video_source::Loader::Loader() :
         CreateGLXVideoSourceSGIX(0),
         DestroyGLXVideoSourceSGIX(0),
+
         is_loaded(true)
 {
     assert(GetCurrentCtx() && "glx_sgix_video_source::Loader initialized without a current context");
 }
 
 
-glx_sgix_video_source::Loader* default_sgix_video_source_loader = 0;
+std::auto_ptr<glx_sgix_video_source::Loader> default_sgix_video_source_loader;
 
 bool load_sgix_video_source() 
 {
-    if (default_sgix_video_source_loader)
-        delete default_sgix_video_source_loader;
-    default_sgix_video_source_loader = new glx_sgix_video_source::Loader();
+    default_sgix_video_source_loader.reset(new glx_sgix_video_source::Loader);
     return default_sgix_video_source_loader->isLoaded();
 }
 
 
 
 glx_ext_visual_rating::Loader::Loader() :
+
         is_loaded(true)
 {
     assert(GetCurrentCtx() && "glx_ext_visual_rating::Loader initialized without a current context");
 }
 
 
-glx_ext_visual_rating::Loader* default_ext_visual_rating_loader = 0;
+std::auto_ptr<glx_ext_visual_rating::Loader> default_ext_visual_rating_loader;
 
 bool load_ext_visual_rating() 
 {
-    if (default_ext_visual_rating_loader)
-        delete default_ext_visual_rating_loader;
-    default_ext_visual_rating_loader = new glx_ext_visual_rating::Loader();
+    default_ext_visual_rating_loader.reset(new glx_ext_visual_rating::Loader);
     return default_ext_visual_rating_loader->isLoaded();
 }
 
         GetContextIDEXT(0),
         ImportContextEXT(0),
         FreeContextEXT(0),
+
         is_loaded(true)
 {
     assert(GetCurrentCtx() && "glx_ext_import_context::Loader initialized without a current context");
 }
 
 
-glx_ext_import_context::Loader* default_ext_import_context_loader = 0;
+std::auto_ptr<glx_ext_import_context::Loader> default_ext_import_context_loader;
 
 bool load_ext_import_context() 
 {
-    if (default_ext_import_context_loader)
-        delete default_ext_import_context_loader;
-    default_ext_import_context_loader = new glx_ext_import_context::Loader();
+    default_ext_import_context_loader.reset(new glx_ext_import_context::Loader);
     return default_ext_import_context_loader->isLoaded();
 }
 
         CreateContextWithConfigSGIX(0),
         GetVisualFromFBConfigSGIX(0),
         GetFBConfigFromVisualSGIX(0),
+
         is_loaded(true)
 {
     assert(GetCurrentCtx() && "glx_sgix_fbconfig::Loader initialized without a current context");
 }
 
 
-glx_sgix_fbconfig::Loader* default_sgix_fbconfig_loader = 0;
+std::auto_ptr<glx_sgix_fbconfig::Loader> default_sgix_fbconfig_loader;
 
 bool load_sgix_fbconfig() 
 {
-    if (default_sgix_fbconfig_loader)
-        delete default_sgix_fbconfig_loader;
-    default_sgix_fbconfig_loader = new glx_sgix_fbconfig::Loader();
+    default_sgix_fbconfig_loader.reset(new glx_sgix_fbconfig::Loader);
     return default_sgix_fbconfig_loader->isLoaded();
 }
 
         QueryGLXPbufferSGIX(0),
         SelectEventSGIX(0),
         GetSelectedEventSGIX(0),
+
         is_loaded(true)
 {
     assert(GetCurrentCtx() && "glx_sgix_pbuffer::Loader initialized without a current context");
 }
 
 
-glx_sgix_pbuffer::Loader* default_sgix_pbuffer_loader = 0;
+std::auto_ptr<glx_sgix_pbuffer::Loader> default_sgix_pbuffer_loader;
 
 bool load_sgix_pbuffer() 
 {
-    if (default_sgix_pbuffer_loader)
-        delete default_sgix_pbuffer_loader;
-    default_sgix_pbuffer_loader = new glx_sgix_pbuffer::Loader();
+    default_sgix_pbuffer_loader.reset(new glx_sgix_pbuffer::Loader);
     return default_sgix_pbuffer_loader->isLoaded();
 }
 
 
 glx_sgi_cushion::Loader::Loader() :
         CushionSGI(0),
+
         is_loaded(true)
 {
     assert(GetCurrentCtx() && "glx_sgi_cushion::Loader initialized without a current context");
 }
 
 
-glx_sgi_cushion::Loader* default_sgi_cushion_loader = 0;
+std::auto_ptr<glx_sgi_cushion::Loader> default_sgi_cushion_loader;
 
 bool load_sgi_cushion() 
 {
-    if (default_sgi_cushion_loader)
-        delete default_sgi_cushion_loader;
-    default_sgi_cushion_loader = new glx_sgi_cushion::Loader();
+    default_sgi_cushion_loader.reset(new glx_sgi_cushion::Loader);
     return default_sgi_cushion_loader->isLoaded();
 }
 
         QueryChannelRectSGIX(0),
         QueryChannelDeltasSGIX(0),
         ChannelRectSyncSGIX(0),
+
         is_loaded(true)
 {
     assert(GetCurrentCtx() && "glx_sgix_video_resize::Loader initialized without a current context");
 }
 
 
-glx_sgix_video_resize::Loader* default_sgix_video_resize_loader = 0;
+std::auto_ptr<glx_sgix_video_resize::Loader> default_sgix_video_resize_loader;
 
 bool load_sgix_video_resize() 
 {
-    if (default_sgix_video_resize_loader)
-        delete default_sgix_video_resize_loader;
-    default_sgix_video_resize_loader = new glx_sgix_video_resize::Loader();
+    default_sgix_video_resize_loader.reset(new glx_sgix_video_resize::Loader);
     return default_sgix_video_resize_loader->isLoaded();
 }
 
 
 glx_sgix_dmbuffer::Loader::Loader() :
         AssociateDMPbufferSGIX(0),
+
         is_loaded(true)
 {
     assert(GetCurrentCtx() && "glx_sgix_dmbuffer::Loader initialized without a current context");
 }
 
 
-glx_sgix_dmbuffer::Loader* default_sgix_dmbuffer_loader = 0;
+std::auto_ptr<glx_sgix_dmbuffer::Loader> default_sgix_dmbuffer_loader;
 
 bool load_sgix_dmbuffer() 
 {
-    if (default_sgix_dmbuffer_loader)
-        delete default_sgix_dmbuffer_loader;
-    default_sgix_dmbuffer_loader = new glx_sgix_dmbuffer::Loader();
+    default_sgix_dmbuffer_loader.reset(new glx_sgix_dmbuffer::Loader);
     return default_sgix_dmbuffer_loader->isLoaded();
 }
 
 
 glx_sgix_swap_group::Loader::Loader() :
         JoinSwapGroupSGIX(0),
+
         is_loaded(true)
 {
     assert(GetCurrentCtx() && "glx_sgix_swap_group::Loader initialized without a current context");
 }
 
 
-glx_sgix_swap_group::Loader* default_sgix_swap_group_loader = 0;
+std::auto_ptr<glx_sgix_swap_group::Loader> default_sgix_swap_group_loader;
 
 bool load_sgix_swap_group() 
 {
-    if (default_sgix_swap_group_loader)
-        delete default_sgix_swap_group_loader;
-    default_sgix_swap_group_loader = new glx_sgix_swap_group::Loader();
+    default_sgix_swap_group_loader.reset(new glx_sgix_swap_group::Loader);
     return default_sgix_swap_group_loader->isLoaded();
 }
 
 glx_sgix_swap_barrier::Loader::Loader() :
         BindSwapBarrierSGIX(0),
         QueryMaxSwapBarriersSGIX(0),
+
         is_loaded(true)
 {
     assert(GetCurrentCtx() && "glx_sgix_swap_barrier::Loader initialized without a current context");
 }
 
 
-glx_sgix_swap_barrier::Loader* default_sgix_swap_barrier_loader = 0;
+std::auto_ptr<glx_sgix_swap_barrier::Loader> default_sgix_swap_barrier_loader;
 
 bool load_sgix_swap_barrier() 
 {
-    if (default_sgix_swap_barrier_loader)
-        delete default_sgix_swap_barrier_loader;
-    default_sgix_swap_barrier_loader = new glx_sgix_swap_barrier::Loader();
+    default_sgix_swap_barrier_loader.reset(new glx_sgix_swap_barrier::Loader);
     return default_sgix_swap_barrier_loader->isLoaded();
 }
 
 
 glx_sun_get_transparent_index::Loader::Loader() :
         GetTransparentIndexSUN(0),
+
         is_loaded(true)
 {
     assert(GetCurrentCtx() && "glx_sun_get_transparent_index::Loader initialized without a current context");
 }
 
 
-glx_sun_get_transparent_index::Loader* default_sun_get_transparent_index_loader = 0;
+std::auto_ptr<glx_sun_get_transparent_index::Loader> default_sun_get_transparent_index_loader;
 
 bool load_sun_get_transparent_index() 
 {
-    if (default_sun_get_transparent_index_loader)
-        delete default_sun_get_transparent_index_loader;
-    default_sun_get_transparent_index_loader = new glx_sun_get_transparent_index::Loader();
+    default_sun_get_transparent_index_loader.reset(new glx_sun_get_transparent_index::Loader);
     return default_sun_get_transparent_index_loader->isLoaded();
 }
 
 
 glx_mesa_copy_sub_buffer::Loader::Loader() :
         CopySubBufferMESA(0),
+
         is_loaded(true)
 {
     assert(GetCurrentCtx() && "glx_mesa_copy_sub_buffer::Loader initialized without a current context");
 }
 
 
-glx_mesa_copy_sub_buffer::Loader* default_mesa_copy_sub_buffer_loader = 0;
+std::auto_ptr<glx_mesa_copy_sub_buffer::Loader> default_mesa_copy_sub_buffer_loader;
 
 bool load_mesa_copy_sub_buffer() 
 {
-    if (default_mesa_copy_sub_buffer_loader)
-        delete default_mesa_copy_sub_buffer_loader;
-    default_mesa_copy_sub_buffer_loader = new glx_mesa_copy_sub_buffer::Loader();
+    default_mesa_copy_sub_buffer_loader.reset(new glx_mesa_copy_sub_buffer::Loader);
     return default_mesa_copy_sub_buffer_loader->isLoaded();
 }
 
 
 glx_mesa_pixmap_colormap::Loader::Loader() :
         CreateGLXPixmapMESA(0),
+
         is_loaded(true)
 {
     assert(GetCurrentCtx() && "glx_mesa_pixmap_colormap::Loader initialized without a current context");
 }
 
 
-glx_mesa_pixmap_colormap::Loader* default_mesa_pixmap_colormap_loader = 0;
+std::auto_ptr<glx_mesa_pixmap_colormap::Loader> default_mesa_pixmap_colormap_loader;
 
 bool load_mesa_pixmap_colormap() 
 {
-    if (default_mesa_pixmap_colormap_loader)
-        delete default_mesa_pixmap_colormap_loader;
-    default_mesa_pixmap_colormap_loader = new glx_mesa_pixmap_colormap::Loader();
+    default_mesa_pixmap_colormap_loader.reset(new glx_mesa_pixmap_colormap::Loader);
     return default_mesa_pixmap_colormap_loader->isLoaded();
 }
 
 
 glx_mesa_release_buffers::Loader::Loader() :
         ReleaseBuffersMESA(0),
+
         is_loaded(true)
 {
     assert(GetCurrentCtx() && "glx_mesa_release_buffers::Loader initialized without a current context");
 }
 
 
-glx_mesa_release_buffers::Loader* default_mesa_release_buffers_loader = 0;
+std::auto_ptr<glx_mesa_release_buffers::Loader> default_mesa_release_buffers_loader;
 
 bool load_mesa_release_buffers() 
 {
-    if (default_mesa_release_buffers_loader)
-        delete default_mesa_release_buffers_loader;
-    default_mesa_release_buffers_loader = new glx_mesa_release_buffers::Loader();
+    default_mesa_release_buffers_loader.reset(new glx_mesa_release_buffers::Loader);
     return default_mesa_release_buffers_loader->isLoaded();
 }
 
 
 glx_mesa_set_3dfx_mode::Loader::Loader() :
         Set3DfxModeMESA(0),
+
         is_loaded(true)
 {
     assert(GetCurrentCtx() && "glx_mesa_set_3dfx_mode::Loader initialized without a current context");
 }
 
 
-glx_mesa_set_3dfx_mode::Loader* default_mesa_set_3dfx_mode_loader = 0;
+std::auto_ptr<glx_mesa_set_3dfx_mode::Loader> default_mesa_set_3dfx_mode_loader;
 
 bool load_mesa_set_3dfx_mode() 
 {
-    if (default_mesa_set_3dfx_mode_loader)
-        delete default_mesa_set_3dfx_mode_loader;
-    default_mesa_set_3dfx_mode_loader = new glx_mesa_set_3dfx_mode::Loader();
+    default_mesa_set_3dfx_mode_loader.reset(new glx_mesa_set_3dfx_mode::Loader);
     return default_mesa_set_3dfx_mode_loader->isLoaded();
 }
 
 
 
 glx_sgix_visual_select_group::Loader::Loader() :
+
         is_loaded(true)
 {
     assert(GetCurrentCtx() && "glx_sgix_visual_select_group::Loader initialized without a current context");
 }
 
 
-glx_sgix_visual_select_group::Loader* default_sgix_visual_select_group_loader = 0;
+std::auto_ptr<glx_sgix_visual_select_group::Loader> default_sgix_visual_select_group_loader;
 
 bool load_sgix_visual_select_group() 
 {
-    if (default_sgix_visual_select_group_loader)
-        delete default_sgix_visual_select_group_loader;
-    default_sgix_visual_select_group_loader = new glx_sgix_visual_select_group::Loader();
+    default_sgix_visual_select_group_loader.reset(new glx_sgix_visual_select_group::Loader);
     return default_sgix_visual_select_group_loader->isLoaded();
 }
 
 
 
 glx_oml_swap_method::Loader::Loader() :
+
         is_loaded(true)
 {
     assert(GetCurrentCtx() && "glx_oml_swap_method::Loader initialized without a current context");
 }
 
 
-glx_oml_swap_method::Loader* default_oml_swap_method_loader = 0;
+std::auto_ptr<glx_oml_swap_method::Loader> default_oml_swap_method_loader;
 
 bool load_oml_swap_method() 
 {
-    if (default_oml_swap_method_loader)
-        delete default_oml_swap_method_loader;
-    default_oml_swap_method_loader = new glx_oml_swap_method::Loader();
+    default_oml_swap_method_loader.reset(new glx_oml_swap_method::Loader);
     return default_oml_swap_method_loader->isLoaded();
 }
 
         SwapBuffersMscOML(0),
         WaitForMscOML(0),
         WaitForSbcOML(0),
+
         is_loaded(true)
 {
     assert(GetCurrentCtx() && "glx_oml_sync_control::Loader initialized without a current context");
 }
 
 
-glx_oml_sync_control::Loader* default_oml_sync_control_loader = 0;
+std::auto_ptr<glx_oml_sync_control::Loader> default_oml_sync_control_loader;
 
 bool load_oml_sync_control() 
 {
-    if (default_oml_sync_control_loader)
-        delete default_oml_sync_control_loader;
-    default_oml_sync_control_loader = new glx_oml_sync_control::Loader();
+    default_oml_sync_control_loader.reset(new glx_oml_sync_control::Loader);
     return default_oml_sync_control_loader->isLoaded();
 }
 
 
 
 glx_nv_float_buffer::Loader::Loader() :
+
         is_loaded(true)
 {
     assert(GetCurrentCtx() && "glx_nv_float_buffer::Loader initialized without a current context");
 }
 
 
-glx_nv_float_buffer::Loader* default_nv_float_buffer_loader = 0;
+std::auto_ptr<glx_nv_float_buffer::Loader> default_nv_float_buffer_loader;
 
 bool load_nv_float_buffer() 
 {
-    if (default_nv_float_buffer_loader)
-        delete default_nv_float_buffer_loader;
-    default_nv_float_buffer_loader = new glx_nv_float_buffer::Loader();
+    default_nv_float_buffer_loader.reset(new glx_nv_float_buffer::Loader);
     return default_nv_float_buffer_loader->isLoaded();
 }
 
         QueryHyperpipeBestAttribSGIX(0),
         HyperpipeAttribSGIX(0),
         QueryHyperpipeAttribSGIX(0),
+
         is_loaded(true)
 {
     assert(GetCurrentCtx() && "glx_sgix_hyperpipe::Loader initialized without a current context");
 }
 
 
-glx_sgix_hyperpipe::Loader* default_sgix_hyperpipe_loader = 0;
+std::auto_ptr<glx_sgix_hyperpipe::Loader> default_sgix_hyperpipe_loader;
 
 bool load_sgix_hyperpipe() 
 {
-    if (default_sgix_hyperpipe_loader)
-        delete default_sgix_hyperpipe_loader;
-    default_sgix_hyperpipe_loader = new glx_sgix_hyperpipe::Loader();
+    default_sgix_hyperpipe_loader.reset(new glx_sgix_hyperpipe::Loader);
     return default_sgix_hyperpipe_loader->isLoaded();
 }
 
 
 glx_mesa_agp_offset::Loader::Loader() :
         GetAGPOffsetMESA(0),
+
         is_loaded(true)
 {
     assert(GetCurrentCtx() && "glx_mesa_agp_offset::Loader initialized without a current context");
 }
 
 
-glx_mesa_agp_offset::Loader* default_mesa_agp_offset_loader = 0;
+std::auto_ptr<glx_mesa_agp_offset::Loader> default_mesa_agp_offset_loader;
 
 bool load_mesa_agp_offset() 
 {
-    if (default_mesa_agp_offset_loader)
-        delete default_mesa_agp_offset_loader;
-    default_mesa_agp_offset_loader = new glx_mesa_agp_offset::Loader();
+    default_mesa_agp_offset_loader.reset(new glx_mesa_agp_offset::Loader);
     return default_mesa_agp_offset_loader->isLoaded();
 }
 
 
 
 glx_ext_fbconfig_packed_float::Loader::Loader() :
+
         is_loaded(true)
 {
     assert(GetCurrentCtx() && "glx_ext_fbconfig_packed_float::Loader initialized without a current context");
 }
 
 
-glx_ext_fbconfig_packed_float::Loader* default_ext_fbconfig_packed_float_loader = 0;
+std::auto_ptr<glx_ext_fbconfig_packed_float::Loader> default_ext_fbconfig_packed_float_loader;
 
 bool load_ext_fbconfig_packed_float() 
 {
-    if (default_ext_fbconfig_packed_float_loader)
-        delete default_ext_fbconfig_packed_float_loader;
-    default_ext_fbconfig_packed_float_loader = new glx_ext_fbconfig_packed_float::Loader();
+    default_ext_fbconfig_packed_float_loader.reset(new glx_ext_fbconfig_packed_float::Loader);
     return default_ext_fbconfig_packed_float_loader->isLoaded();
 }
 
 
 
 glx_ext_framebuffer_srgb::Loader::Loader() :
+
         is_loaded(true)
 {
     assert(GetCurrentCtx() && "glx_ext_framebuffer_srgb::Loader initialized without a current context");
 }
 
 
-glx_ext_framebuffer_srgb::Loader* default_ext_framebuffer_srgb_loader = 0;
+std::auto_ptr<glx_ext_framebuffer_srgb::Loader> default_ext_framebuffer_srgb_loader;
 
 bool load_ext_framebuffer_srgb() 
 {
-    if (default_ext_framebuffer_srgb_loader)
-        delete default_ext_framebuffer_srgb_loader;
-    default_ext_framebuffer_srgb_loader = new glx_ext_framebuffer_srgb::Loader();
+    default_ext_framebuffer_srgb_loader.reset(new glx_ext_framebuffer_srgb::Loader);
     return default_ext_framebuffer_srgb_loader->isLoaded();
 }
 
 glx_ext_texture_from_pixmap::Loader::Loader() :
         BindTexImageEXT(0),
         ReleaseTexImageEXT(0),
+
         is_loaded(true)
 {
     assert(GetCurrentCtx() && "glx_ext_texture_from_pixmap::Loader initialized without a current context");
 }
 
 
-glx_ext_texture_from_pixmap::Loader* default_ext_texture_from_pixmap_loader = 0;
+std::auto_ptr<glx_ext_texture_from_pixmap::Loader> default_ext_texture_from_pixmap_loader;
 
 bool load_ext_texture_from_pixmap() 
 {
-    if (default_ext_texture_from_pixmap_loader)
-        delete default_ext_texture_from_pixmap_loader;
-    default_ext_texture_from_pixmap_loader = new glx_ext_texture_from_pixmap::Loader();
+    default_ext_texture_from_pixmap_loader.reset(new glx_ext_texture_from_pixmap::Loader);
     return default_ext_texture_from_pixmap_loader->isLoaded();
 }
 
 glx_nv_present_video::Loader::Loader() :
         EnumerateVideoDevicesNV(0),
         BindVideoDeviceNV(0),
+
         is_loaded(true)
 {
     assert(GetCurrentCtx() && "glx_nv_present_video::Loader initialized without a current context");
 }
 
 
-glx_nv_present_video::Loader* default_nv_present_video_loader = 0;
+std::auto_ptr<glx_nv_present_video::Loader> default_nv_present_video_loader;
 
 bool load_nv_present_video() 
 {
-    if (default_nv_present_video_loader)
-        delete default_nv_present_video_loader;
-    default_nv_present_video_loader = new glx_nv_present_video::Loader();
+    default_nv_present_video_loader.reset(new glx_nv_present_video::Loader);
     return default_nv_present_video_loader->isLoaded();
 }
 
         ReleaseVideoImageNV(0),
         SendPbufferToVideoNV(0),
         GetVideoInfoNV(0),
+
         is_loaded(true)
 {
     assert(GetCurrentCtx() && "glx_nv_video_output::Loader initialized without a current context");
 }
 
 
-glx_nv_video_output::Loader* default_nv_video_output_loader = 0;
+std::auto_ptr<glx_nv_video_output::Loader> default_nv_video_output_loader;
 
 bool load_nv_video_output() 
 {
-    if (default_nv_video_output_loader)
-        delete default_nv_video_output_loader;
-    default_nv_video_output_loader = new glx_nv_video_output::Loader();
+    default_nv_video_output_loader.reset(new glx_nv_video_output::Loader);
     return default_nv_video_output_loader->isLoaded();
 }
 
         QueryMaxSwapGroupsNV(0),
         QueryFrameCountNV(0),
         ResetFrameCountNV(0),
+
         is_loaded(true)
 {
     assert(GetCurrentCtx() && "glx_nv_swap_group::Loader initialized without a current context");
 }
 
 
-glx_nv_swap_group::Loader* default_nv_swap_group_loader = 0;
+std::auto_ptr<glx_nv_swap_group::Loader> default_nv_swap_group_loader;
 
 bool load_nv_swap_group() 
 {
-    if (default_nv_swap_group_loader)
-        delete default_nv_swap_group_loader;
-    default_nv_swap_group_loader = new glx_nv_swap_group::Loader();
+    default_nv_swap_group_loader.reset(new glx_nv_swap_group::Loader);
     return default_nv_swap_group_loader->isLoaded();
 }
 
         LockVideoCaptureDeviceNV(0),
         QueryVideoCaptureDeviceNV(0),
         ReleaseVideoCaptureDeviceNV(0),
+
         is_loaded(true)
 {
     assert(GetCurrentCtx() && "glx_nv_video_capture::Loader initialized without a current context");
 }
 
 
-glx_nv_video_capture::Loader* default_nv_video_capture_loader = 0;
+std::auto_ptr<glx_nv_video_capture::Loader> default_nv_video_capture_loader;
 
 bool load_nv_video_capture() 
 {
-    if (default_nv_video_capture_loader)
-        delete default_nv_video_capture_loader;
-    default_nv_video_capture_loader = new glx_nv_video_capture::Loader();
+    default_nv_video_capture_loader.reset(new glx_nv_video_capture::Loader);
     return default_nv_video_capture_loader->isLoaded();
 }
 
 
 glx_ext_swap_control::Loader::Loader() :
         SwapIntervalEXT(0),
+
         is_loaded(true)
 {
     assert(GetCurrentCtx() && "glx_ext_swap_control::Loader initialized without a current context");
 }
 
 
-glx_ext_swap_control::Loader* default_ext_swap_control_loader = 0;
+std::auto_ptr<glx_ext_swap_control::Loader> default_ext_swap_control_loader;
 
 bool load_ext_swap_control() 
 {
-    if (default_ext_swap_control_loader)
-        delete default_ext_swap_control_loader;
-    default_ext_swap_control_loader = new glx_ext_swap_control::Loader();
+    default_ext_swap_control_loader.reset(new glx_ext_swap_control::Loader);
     return default_ext_swap_control_loader->isLoaded();
 }
 
 
 glx_nv_copy_image::Loader::Loader() :
         CopyImageSubDataNV(0),
+
         is_loaded(true)
 {
     assert(GetCurrentCtx() && "glx_nv_copy_image::Loader initialized without a current context");
 }
 
 
-glx_nv_copy_image::Loader* default_nv_copy_image_loader = 0;
+std::auto_ptr<glx_nv_copy_image::Loader> default_nv_copy_image_loader;
 
 bool load_nv_copy_image() 
 {
-    if (default_nv_copy_image_loader)
-        delete default_nv_copy_image_loader;
-    default_nv_copy_image_loader = new glx_nv_copy_image::Loader();
+    default_nv_copy_image_loader.reset(new glx_nv_copy_image::Loader);
     return default_nv_copy_image_loader->isLoaded();
 }
 
 
 
 glx_intel_swap_event::Loader::Loader() :
+
         is_loaded(true)
 {
     assert(GetCurrentCtx() && "glx_intel_swap_event::Loader initialized without a current context");
 }
 
 
-glx_intel_swap_event::Loader* default_intel_swap_event_loader = 0;
+std::auto_ptr<glx_intel_swap_event::Loader> default_intel_swap_event_loader;
 
 bool load_intel_swap_event() 
 {
-    if (default_intel_swap_event_loader)
-        delete default_intel_swap_event_loader;
-    default_intel_swap_event_loader = new glx_intel_swap_event::Loader();
+    default_intel_swap_event_loader.reset(new glx_intel_swap_event::Loader);
     return default_intel_swap_event_loader->isLoaded();
 }
 
 
 
 glx_nv_multisample_coverage::Loader::Loader() :
+
         is_loaded(true)
 {
     assert(GetCurrentCtx() && "glx_nv_multisample_coverage::Loader initialized without a current context");
 }
 
 
-glx_nv_multisample_coverage::Loader* default_nv_multisample_coverage_loader = 0;
+std::auto_ptr<glx_nv_multisample_coverage::Loader> default_nv_multisample_coverage_loader;
 
 bool load_nv_multisample_coverage() 
 {
-    if (default_nv_multisample_coverage_loader)
-        delete default_nv_multisample_coverage_loader;
-    default_nv_multisample_coverage_loader = new glx_nv_multisample_coverage::Loader();
+    default_nv_multisample_coverage_loader.reset(new glx_nv_multisample_coverage::Loader);
     return default_nv_multisample_coverage_loader->isLoaded();
 }