epoc32/include/tools/stlport/stl/_tempbuf.c
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:33:34 +0100
branchSymbian3
changeset 4 837f303aceeb
permissions -rw-r--r--
Current Symbian^3 public API header files (from PDK 3.0.h)
This is the epoc32/include tree with the "platform" subtrees removed, and
all but a selected few mbg and rsg files removed.
williamr@4
     1
/*
williamr@4
     2
 *
williamr@4
     3
 *
williamr@4
     4
 * Copyright (c) 1994
williamr@4
     5
 * Hewlett-Packard Company
williamr@4
     6
 *
williamr@4
     7
 * Copyright (c) 1996,1997
williamr@4
     8
 * Silicon Graphics Computer Systems, Inc.
williamr@4
     9
 *
williamr@4
    10
 * Copyright (c) 1997
williamr@4
    11
 * Moscow Center for SPARC Technology
williamr@4
    12
 *
williamr@4
    13
 * Copyright (c) 1999
williamr@4
    14
 * Boris Fomitchev
williamr@4
    15
 *
williamr@4
    16
 * This material is provided "as is", with absolutely no warranty expressed
williamr@4
    17
 * or implied. Any use is at your own risk.
williamr@4
    18
 *
williamr@4
    19
 * Permission to use or copy this software for any purpose is hereby granted
williamr@4
    20
 * without fee, provided the above notices are retained on all copies.
williamr@4
    21
 * Permission to modify the code and to distribute modified code is granted,
williamr@4
    22
 * provided the above notices are retained, and a notice that the code was
williamr@4
    23
 * modified is included with the above copyright notice.
williamr@4
    24
 *
williamr@4
    25
 */
williamr@4
    26
#ifndef _STLP_TEMPBUF_C
williamr@4
    27
#define _STLP_TEMPBUF_C
williamr@4
    28
williamr@4
    29
#ifndef _STLP_INTERNAL_TEMPBUF_H
williamr@4
    30
# include <stl/_tempbuf.h>
williamr@4
    31
#endif
williamr@4
    32
williamr@4
    33
_STLP_BEGIN_NAMESPACE
williamr@4
    34
williamr@4
    35
template <class _Tp>
williamr@4
    36
pair<_Tp*, ptrdiff_t> _STLP_CALL
williamr@4
    37
__get_temporary_buffer(ptrdiff_t __len, _Tp*)
williamr@4
    38
{
williamr@4
    39
  if (__len > ptrdiff_t(INT_MAX / sizeof(_Tp)))
williamr@4
    40
    __len = INT_MAX / sizeof(_Tp);
williamr@4
    41
williamr@4
    42
  while (__len > 0) {
williamr@4
    43
    _Tp* __tmp = (_Tp*) malloc((size_t)__len * sizeof(_Tp));
williamr@4
    44
    if (__tmp != 0)
williamr@4
    45
      return pair<_Tp*, ptrdiff_t>(__tmp, __len);
williamr@4
    46
    __len /= 2;
williamr@4
    47
  }
williamr@4
    48
williamr@4
    49
  return pair<_Tp*, ptrdiff_t>((_Tp*)0, 0);
williamr@4
    50
}
williamr@4
    51
_STLP_END_NAMESPACE
williamr@4
    52
williamr@4
    53
#endif /*  _STLP_TEMPBUF_C */
williamr@4
    54
williamr@4
    55
// Local Variables:
williamr@4
    56
// mode:C++
williamr@4
    57
// End: