williamr@2: /* williamr@2: * williamr@2: * williamr@2: * Copyright (c) 1994 williamr@2: * Hewlett-Packard Company williamr@2: * williamr@2: * Copyright (c) 1996,1997 williamr@2: * Silicon Graphics Computer Systems, Inc. williamr@2: * williamr@2: * Copyright (c) 1997 williamr@2: * Moscow Center for SPARC Technology williamr@2: * williamr@4: * Copyright (c) 1999 williamr@2: * Boris Fomitchev williamr@2: * williamr@2: * This material is provided "as is", with absolutely no warranty expressed williamr@2: * or implied. Any use is at your own risk. williamr@2: * williamr@4: * Permission to use or copy this software for any purpose is hereby granted williamr@2: * without fee, provided the above notices are retained on all copies. williamr@2: * Permission to modify the code and to distribute modified code is granted, williamr@2: * provided the above notices are retained, and a notice that the code was williamr@2: * modified is included with the above copyright notice. williamr@2: * williamr@2: */ williamr@2: #ifndef _STLP_TEMPBUF_C williamr@2: #define _STLP_TEMPBUF_C williamr@2: williamr@2: #ifndef _STLP_INTERNAL_TEMPBUF_H williamr@2: # include williamr@2: #endif williamr@2: williamr@2: _STLP_BEGIN_NAMESPACE williamr@2: williamr@2: template williamr@4: pair<_Tp*, ptrdiff_t> _STLP_CALL williamr@2: __get_temporary_buffer(ptrdiff_t __len, _Tp*) williamr@2: { williamr@2: if (__len > ptrdiff_t(INT_MAX / sizeof(_Tp))) williamr@2: __len = INT_MAX / sizeof(_Tp); williamr@2: williamr@2: while (__len > 0) { williamr@2: _Tp* __tmp = (_Tp*) malloc((size_t)__len * sizeof(_Tp)); williamr@2: if (__tmp != 0) williamr@2: return pair<_Tp*, ptrdiff_t>(__tmp, __len); williamr@2: __len /= 2; williamr@2: } williamr@2: williamr@2: return pair<_Tp*, ptrdiff_t>((_Tp*)0, 0); williamr@2: } williamr@2: _STLP_END_NAMESPACE williamr@2: williamr@2: #endif /* _STLP_TEMPBUF_C */ williamr@2: williamr@2: // Local Variables: williamr@2: // mode:C++ williamr@2: // End: