unew.cpp revision 9066cfe9886ac131c34d59ed0e2d287b0e3c0087
1// This file is part of the ustl library, an STL implementation. 2// 3// Copyright (C) 2005 by Mike Sharov <msharov@users.sourceforge.net> 4// This file is free software, distributed under the MIT License. 5// 6// unew.cc 7// 8 9#include "unew.h" 10#include <stdlib.h> 11 12#if PLATFORM_ANDROID 13#include <stdio.h> 14#endif 15 16void* throwing_malloc (size_t n) throw (ustl::bad_alloc) 17{ 18 void* p = malloc (n); 19 if (!p) 20#if PLATFORM_ANDROID 21 printf("bad alloc\n"); 22#else 23 throw ustl::bad_alloc (n); 24#endif 25 return (p); 26} 27 28void free_nullok (void* p) throw() 29{ 30 if (p) 31 free (p); 32} 33 34