epoc32/include/tools/stlport/stl/_tempbuf.c
branchSymbian3
changeset 4 837f303aceeb
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/epoc32/include/tools/stlport/stl/_tempbuf.c	Wed Mar 31 12:33:34 2010 +0100
     1.3 @@ -0,0 +1,57 @@
     1.4 +/*
     1.5 + *
     1.6 + *
     1.7 + * Copyright (c) 1994
     1.8 + * Hewlett-Packard Company
     1.9 + *
    1.10 + * Copyright (c) 1996,1997
    1.11 + * Silicon Graphics Computer Systems, Inc.
    1.12 + *
    1.13 + * Copyright (c) 1997
    1.14 + * Moscow Center for SPARC Technology
    1.15 + *
    1.16 + * Copyright (c) 1999
    1.17 + * Boris Fomitchev
    1.18 + *
    1.19 + * This material is provided "as is", with absolutely no warranty expressed
    1.20 + * or implied. Any use is at your own risk.
    1.21 + *
    1.22 + * Permission to use or copy this software for any purpose is hereby granted
    1.23 + * without fee, provided the above notices are retained on all copies.
    1.24 + * Permission to modify the code and to distribute modified code is granted,
    1.25 + * provided the above notices are retained, and a notice that the code was
    1.26 + * modified is included with the above copyright notice.
    1.27 + *
    1.28 + */
    1.29 +#ifndef _STLP_TEMPBUF_C
    1.30 +#define _STLP_TEMPBUF_C
    1.31 +
    1.32 +#ifndef _STLP_INTERNAL_TEMPBUF_H
    1.33 +# include <stl/_tempbuf.h>
    1.34 +#endif
    1.35 +
    1.36 +_STLP_BEGIN_NAMESPACE
    1.37 +
    1.38 +template <class _Tp>
    1.39 +pair<_Tp*, ptrdiff_t> _STLP_CALL
    1.40 +__get_temporary_buffer(ptrdiff_t __len, _Tp*)
    1.41 +{
    1.42 +  if (__len > ptrdiff_t(INT_MAX / sizeof(_Tp)))
    1.43 +    __len = INT_MAX / sizeof(_Tp);
    1.44 +
    1.45 +  while (__len > 0) {
    1.46 +    _Tp* __tmp = (_Tp*) malloc((size_t)__len * sizeof(_Tp));
    1.47 +    if (__tmp != 0)
    1.48 +      return pair<_Tp*, ptrdiff_t>(__tmp, __len);
    1.49 +    __len /= 2;
    1.50 +  }
    1.51 +
    1.52 +  return pair<_Tp*, ptrdiff_t>((_Tp*)0, 0);
    1.53 +}
    1.54 +_STLP_END_NAMESPACE
    1.55 +
    1.56 +#endif /*  _STLP_TEMPBUF_C */
    1.57 +
    1.58 +// Local Variables:
    1.59 +// mode:C++
    1.60 +// End: