summaryrefslogtreecommitdiffstats
path: root/WebKit/android/stlport/stl/_alloc.c
diff options
context:
space:
mode:
authorPatrick Scott <phanna@android.com>2009-10-16 15:11:59 -0400
committerPatrick Scott <phanna@android.com>2009-12-02 14:33:28 -0500
commita47ab5294213cca2741f453b450b02666e08cac8 (patch)
tree428576772386a65df40bbc18d1f7b41b06a01946 /WebKit/android/stlport/stl/_alloc.c
parentedac9050e2c3239d294f9039c54a31058ab0a783 (diff)
downloadexternal_webkit-a47ab5294213cca2741f453b450b02666e08cac8.zip
external_webkit-a47ab5294213cca2741f453b450b02666e08cac8.tar.gz
external_webkit-a47ab5294213cca2741f453b450b02666e08cac8.tar.bz2
Use STLPort instead of our stripped version.
This fixes the simulator build and allows us to get closer to sharing code with chromium. STLPort was copied with minor edits from the Android port of gears.
Diffstat (limited to 'WebKit/android/stlport/stl/_alloc.c')
-rw-r--r--WebKit/android/stlport/stl/_alloc.c88
1 files changed, 88 insertions, 0 deletions
diff --git a/WebKit/android/stlport/stl/_alloc.c b/WebKit/android/stlport/stl/_alloc.c
new file mode 100644
index 0000000..ad6656c
--- /dev/null
+++ b/WebKit/android/stlport/stl/_alloc.c
@@ -0,0 +1,88 @@
+/*
+ *
+ * Copyright (c) 1996,1997
+ * Silicon Graphics Computer Systems, Inc.
+ *
+ * Copyright (c) 1997
+ * Moscow Center for SPARC Technology
+ *
+ * Copyright (c) 1999
+ * Boris Fomitchev
+ *
+ * This material is provided "as is", with absolutely no warranty expressed
+ * or implied. Any use is at your own risk.
+ *
+ * Permission to use or copy this software for any purpose is hereby granted
+ * without fee, provided the above notices are retained on all copies.
+ * Permission to modify the code and to distribute modified code is granted,
+ * provided the above notices are retained, and a notice that the code was
+ * modified is included with the above copyright notice.
+ *
+ */
+#ifndef _STLP_ALLOC_C
+#define _STLP_ALLOC_C
+
+#ifndef _STLP_INTERNAL_ALLOC_H
+# include <stl/_alloc.h>
+#endif
+
+#if defined (__WATCOMC__)
+# pragma warning 13 9
+# pragma warning 367 9
+# pragma warning 368 9
+#endif
+
+_STLP_BEGIN_NAMESPACE
+
+template <class _Alloc>
+void * _STLP_CALL __debug_alloc<_Alloc>::allocate(size_t __n) {
+ size_t __total_extra = __extra_before_chunk() + __extra_after_chunk();
+ size_t __real_n = __n + __total_extra;
+ if (__real_n < __n) {
+ //It means that we rolled on size_t, __n must be very large, lets hope
+ //that allocating it will raised a bad_alloc exception:
+ __real_n = __n + (__total_extra - __real_n - 1);
+ }
+ __alloc_header *__result = (__alloc_header *)__allocator_type::allocate(__real_n);
+ memset((char*)__result, __shred_byte, __real_n * sizeof(value_type));
+ __result->__magic = __magic;
+ __result->__type_size = sizeof(value_type);
+ __result->_M_size = (_STLP_UINT32_T)__n;
+ return ((char*)__result) + (long)__extra_before;
+}
+
+template <class _Alloc>
+void _STLP_CALL
+__debug_alloc<_Alloc>::deallocate(void *__p, size_t __n) {
+ __alloc_header * __real_p = (__alloc_header*)((char *)__p -(long)__extra_before);
+ // check integrity
+ _STLP_VERBOSE_ASSERT(__real_p->__magic != __deleted_magic, _StlMsg_DBA_DELETED_TWICE)
+ _STLP_VERBOSE_ASSERT(__real_p->__magic == __magic, _StlMsg_DBA_NEVER_ALLOCATED)
+ _STLP_VERBOSE_ASSERT(__real_p->__type_size == 1,_StlMsg_DBA_TYPE_MISMATCH)
+ _STLP_VERBOSE_ASSERT(__real_p->_M_size == __n, _StlMsg_DBA_SIZE_MISMATCH)
+ // check pads on both sides
+ unsigned char* __tmp;
+ for (__tmp = (unsigned char*)(__real_p + 1); __tmp < (unsigned char*)__p; ++__tmp) {
+ _STLP_VERBOSE_ASSERT(*__tmp == __shred_byte, _StlMsg_DBA_UNDERRUN)
+ }
+
+ size_t __real_n = __n + __extra_before_chunk() + __extra_after_chunk();
+
+ for (__tmp= ((unsigned char*)__p) + __n * sizeof(value_type);
+ __tmp < ((unsigned char*)__real_p) + __real_n ; ++__tmp) {
+ _STLP_VERBOSE_ASSERT(*__tmp == __shred_byte, _StlMsg_DBA_OVERRUN)
+ }
+
+ // that may be unfortunate, just in case
+ __real_p->__magic = __deleted_magic;
+ memset((char*)__p, __shred_byte, __n * sizeof(value_type));
+ __allocator_type::deallocate(__real_p, __real_n);
+}
+
+_STLP_END_NAMESPACE
+
+#endif /* _STLP_ALLOC_C */
+
+// Local Variables:
+// mode:C++
+// End: