From b7190ee2e57c7e0fe78473275d9b94397fa1ddee Mon Sep 17 00:00:00 2001 From: akir Date: Thu, 21 Oct 2004 10:03:43 +0000 Subject: fix for mipspro: no 'new(nothrow)' available for MIPSpro Compilers: Version 7.3.1.3m --- src/FbTk/TextureRender.cc | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/src/FbTk/TextureRender.cc b/src/FbTk/TextureRender.cc index d34aafe..b2c3831 100644 --- a/src/FbTk/TextureRender.cc +++ b/src/FbTk/TextureRender.cc @@ -22,7 +22,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: TextureRender.cc,v 1.13 2004/10/06 19:19:43 akir Exp $ +// $Id: TextureRender.cc,v 1.14 2004/10/21 10:03:43 akir Exp $ #include "TextureRender.hh" @@ -41,6 +41,14 @@ #endif using namespace std; +// mipspro has no new(nothrow) +#if defined sgi && ! defined GCC +#define FB_new_nothrow new +#else +#warning yeah, thats the way +#define FB_new_nothrow new(std::nothrow) +#endif + namespace FbTk { TextureRender::TextureRender(ImageControl &imgctrl, @@ -98,28 +106,34 @@ Pixmap TextureRender::render(const FbTk::Texture &texture) { } void TextureRender::allocateColorTables() { - red = new(nothrow) unsigned char[width * height]; _FB_USES_NLS; + + const size_t size = width * height; + red = FB_new_nothrow unsigned char[size]; + if (red == 0) { char sbuf[128]; - sprintf(sbuf, "%d", width*height); - throw string("TextureRender::TextureRender(): " + string(_FBTKTEXT(Error, OutOfMemoryRed, "Out of memory while allocating red buffer.", "")) + string(sbuf)); + sprintf(sbuf, "%d", size); + throw std::string("TextureRender::TextureRender(): " + + std::string(_FBTKTEXT(Error, OutOfMemoryRed, "Out of memory while allocating red buffer.", "")) + string(sbuf)); } - green = new(nothrow) unsigned char[width * height]; + green = FB_new_nothrow unsigned char[size]; if (green == 0) { char sbuf[128]; - sprintf(sbuf, "%d", width*height); - throw string("TextureRender::TextureRender(): " +string(_FBTKTEXT(Error, OutOfMemoryGreen, "Out of memory while allocating green buffer.", ""))+ string(sbuf)); + sprintf(sbuf, "%d", size); + throw std::string("TextureRender::TextureRender(): " + + std::string(_FBTKTEXT(Error, OutOfMemoryGreen, "Out of memory while allocating green buffer.", ""))+ string(sbuf)); } - blue = new(nothrow) unsigned char[width * height]; + blue = FB_new_nothrow unsigned char[size]; if (blue == 0) { char sbuf[128]; - sprintf(sbuf, "%d", width*height); - throw string("TextureRender::TextureRender(): " +string(_FBTKTEXT(Error, OutOfMemoryBlue, "Out of memory while allocating blue buffer.", ""))+ string(sbuf)); + sprintf(sbuf, "%d", size); + throw std::string("TextureRender::TextureRender(): " + + std::string(_FBTKTEXT(Error, OutOfMemoryBlue, "Out of memory while allocating blue buffer.", ""))+ string(sbuf)); } -- cgit v0.11.2