From: Lars Gullik Bjønnes Date: Tue, 20 Feb 2001 13:39:03 +0000 (+0000) Subject: make smart_ptr.hpp usable without exceptions X-Git-Tag: 1.6.10~21584 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=1b0943f20d0391aa3379c44161c3ff414946befd;p=features.git make smart_ptr.hpp usable without exceptions git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1569 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/boost/boost/smart_ptr.hpp b/boost/boost/smart_ptr.hpp index 162b458bd7..0f6d559d59 100644 --- a/boost/boost/smart_ptr.hpp +++ b/boost/boost/smart_ptr.hpp @@ -1,3 +1,11 @@ +// Baruch Even baruch@ev-en.org 2001-02-20 +// This version is a modified version for use in LyX +// The modifications are done in order to use it where exceptions are disabled +// Currently it has no "no memory" checks in place, asserts are probably the +// only real way. +// all changed are #ifded'ed by LYX_NO_EXCEPTIONS +#define LYX_NO_EXCEPTIONS + // Boost smart_ptr.hpp header file -----------------------------------------// // (C) Copyright Greg Colvin and Beman Dawes 1998, 1999. Permission to copy, @@ -129,8 +137,12 @@ template class shared_ptr { typedef T element_type; explicit shared_ptr(T* p =0) : px(p) { +#ifndef LYX_NO_EXCEPTIONS try { pn = new long(1); } // fix: prevent leak if new throws catch (...) { delete p; throw; } +#else + pn = new long(1); +#endif } shared_ptr(const shared_ptr& r) : px(r.px) { ++*(pn = r.pn); } // never throws @@ -200,12 +212,16 @@ template class shared_ptr { if ( px == p ) return; // fix: self-assignment safe if (--*pn == 0) { delete px; } else { // allocate new reference counter +#ifndef LYX_NO_EXCEPTIONS try { pn = new long; } // fix: prevent leak if new throws catch (...) { ++*pn; // undo effect of --*pn above to meet effects guarantee delete p; throw; } // catch +#else + pn = new long; +#endif } // allocate new reference counter *pn = 1; px = p; @@ -277,8 +293,12 @@ template class shared_array { typedef T element_type; explicit shared_array(T* p =0) : px(p) { +#ifndef LYX_NO_EXCEPTIONS try { pn = new long(1); } // fix: prevent leak if new throws catch (...) { delete [] p; throw; } +#else + pn = new long(1); +#endif } shared_array(const shared_array& r) : px(r.px) // never throws @@ -299,12 +319,16 @@ template class shared_array { if ( px == p ) return; // fix: self-assignment safe if (--*pn == 0) { delete [] px; } else { // allocate new reference counter +#ifndef LYX_NO_EXCEPTIONS try { pn = new long; } // fix: prevent leak if new throws catch (...) { ++*pn; // undo effect of --*pn above to meet effects guarantee delete [] p; throw; } // catch +#else + pn = new long; +#endif } // allocate new reference counter *pn = 1; px = p;