Changes For Bug 352
[oota-llvm.git] / include / llvm / Support / MallocAllocator.h
index 24f1a43c8d124f454777cbad50acb18f23715bee..c17517e2a0c7e4bb7e6e08f0a9c55424c615572a 100644 (file)
@@ -1,4 +1,4 @@
-//===-- Support/MallocAllocator.h - Allocator using malloc/free -*- C++ -*-===//
+//===-- llvm/Support/MallocAllocator.h --------------------------*- C++ -*-===//
 // 
 //                     The LLVM Compiler Infrastructure
 //
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef SUPPORT_MALLOCALLOCATOR_H
-#define SUPPORT_MALLOCALLOCATOR_H
+#ifndef LLVM_SUPPORT_MALLOCALLOCATOR_H
+#define LLVM_SUPPORT_MALLOCALLOCATOR_H
 
 #include <cstdlib>
 #include <memory>
 
+namespace llvm {
+
 template<typename T>
 struct MallocAllocator {
   typedef size_t size_type;
@@ -45,15 +47,15 @@ struct MallocAllocator {
   size_type max_size() const { return ~0 / sizeof(T); }
   
   static pointer allocate(size_t n, void* hint = 0) {
-    return (pointer)malloc(n*sizeof(T));
+    return static_cast<pointer>(malloc(n*sizeof(T)));
   }
 
   static void deallocate(pointer p, size_t n) {
-    free((void*)p);
+    free(static_cast<void*>(p));
   }
 
   void construct(pointer p, const T &val) {
-    new((void*)p) T(val);
+    new(static_cast<void*>(p)) T(val);
   }
   void destroy(pointer p) {
     p->~T();
@@ -68,14 +70,15 @@ template<typename T>
 inline bool operator!=(const MallocAllocator<T>&, const MallocAllocator<T>&) {
   return false;
 }
+} // End llvm namespace
 
 namespace std {
   template<typename Type, typename Type2>
-  struct _Alloc_traits<Type, ::MallocAllocator<Type2> > {
+  struct _Alloc_traits<Type, ::llvm::MallocAllocator<Type2> > {
     static const bool _S_instanceless = true;
-    typedef ::MallocAllocator<Type> base_alloc_type;
-    typedef ::MallocAllocator<Type> _Alloc_type;
-    typedef ::MallocAllocator<Type> allocator_type;
+    typedef ::llvm::MallocAllocator<Type> base_alloc_type;
+    typedef ::llvm::MallocAllocator<Type> _Alloc_type;
+    typedef ::llvm::MallocAllocator<Type> allocator_type;
   };
 }