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