This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Indentation fixes for stl_alloc.h


In the process of playing with allocators, I noticed some oddities in
stl_alloc.h.  These bring them into line with what I think C++STYLE says,
but I'd like review and approval before I check them in.

- The simple functions should be indented, as per the example two_line.

- 'return' is not a function call

- template
    class simple_alloc
    {

  not

  template
  class simple_alloc
  {

- finally, a specialization of __allocator was declared as class,
  not struct, but never had a public access specifier.  Very odd.



Index: include/bits/stl_alloc.h
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/include/bits/stl_alloc.h,v
retrieving revision 1.23
diff -u -3 -r1.23 stl_alloc.h
--- include/bits/stl_alloc.h	20 Jul 2002 06:26:26 -0000	1.23
+++ include/bits/stl_alloc.h	20 Aug 2002 01:03:22 -0000
@@ -104,13 +104,14 @@
   public:
     static void*
     allocate(size_t __n)
-    { return ::operator new(__n); }
+      { return ::operator new(__n); }
 
     static void
     deallocate(void* __p, size_t)
-    { ::operator delete(__p); }
+      { ::operator delete(__p); }
   };
 
+
   /**
    *  @if maint
    *  A malloc-based allocator.  Typically slower than the
@@ -142,7 +143,7 @@
 
       static void
       deallocate(void* __p, size_t /* __n */)
-      { free(__p); }
+        { free(__p); }
 
 #ifdef _GLIBCPP_DEPRECATED
       static void*
@@ -159,7 +160,7 @@
       {
         void (* __old)() = __malloc_alloc_oom_handler;
         __malloc_alloc_oom_handler = __f;
-        return(__old);
+        return __old;
       }
     };
 
@@ -179,11 +180,11 @@
         {
           __my_malloc_handler = __malloc_alloc_oom_handler;
           if (0 == __my_malloc_handler)
-          std::__throw_bad_alloc();
+            std::__throw_bad_alloc();
           (*__my_malloc_handler)();
           __result = malloc(__n);
           if (__result)
-            return(__result);
+            return __result;
         }
     }
 
@@ -204,7 +205,7 @@
           (*__my_malloc_handler)();
           __result = realloc(__p, __n);
           if (__result)
-            return(__result);
+            return __result;
         }
     }
 #endif
@@ -230,25 +231,25 @@
    *  (See @link Allocators allocators info @endlink for more.)
    */
   template<typename _Tp, typename _Alloc>
-  class __simple_alloc
-  {
-  public:
-    static _Tp*
-    allocate(size_t __n)
-    { return 0 == __n ? 0 : (_Tp*) _Alloc::allocate(__n * sizeof (_Tp)); }
-
-    static _Tp*
-    allocate()
-    { return (_Tp*) _Alloc::allocate(sizeof (_Tp)); }
-
-    static void
-    deallocate(_Tp* __p, size_t __n)
-    { if (0 != __n) _Alloc::deallocate(__p, __n * sizeof (_Tp)); }
-
-    static void
-    deallocate(_Tp* __p)
-    { _Alloc::deallocate(__p, sizeof (_Tp)); }
-  };
+    class __simple_alloc
+    {
+    public:
+      static _Tp*
+      allocate(size_t __n)
+        { return 0 == __n ? 0 : (_Tp*) _Alloc::allocate(__n * sizeof (_Tp)); }
+  
+      static _Tp*
+      allocate()
+        { return (_Tp*) _Alloc::allocate(sizeof (_Tp)); }
+  
+      static void
+      deallocate(_Tp* __p, size_t __n)
+        { if (0 != __n) _Alloc::deallocate(__p, __n * sizeof (_Tp)); }
+  
+      static void
+      deallocate(_Tp* __p)
+        { _Alloc::deallocate(__p, sizeof (_Tp)); }
+    };
 
 
   /**
@@ -479,7 +480,7 @@
         {
           __result = _S_start_free;
           _S_start_free += __total_bytes;
-          return(__result);
+          return __result ;
         }
       else if (__bytes_left >= __size)
         {
@@ -487,7 +488,7 @@
           __total_bytes = __size * __nobjs;
           __result = _S_start_free;
           _S_start_free += __total_bytes;
-          return(__result);
+          return __result;
         }
       else
         {
@@ -521,7 +522,7 @@
                       *__my_free_list = __p -> _M_free_list_link;
                       _S_start_free = (char*)__p;
                       _S_end_free = _S_start_free + __i;
-                      return(_S_chunk_alloc(__size, __nobjs));
+                      return _S_chunk_alloc(__size, __nobjs);
                       // Any leftover piece will eventually make it to the
                       // right free list.
                     }
@@ -533,7 +534,7 @@
             }
           _S_heap_size += __bytes_to_get;
           _S_end_free = _S_start_free + __bytes_to_get;
-          return(_S_chunk_alloc(__size, __nobjs));
+          return _S_chunk_alloc(__size, __nobjs);
         }
     }
 
@@ -554,7 +555,7 @@
       int __i;
 
       if (1 == __nobjs)
-        return(__chunk);
+        return __chunk;
       __my_free_list = _S_free_list + _S_freelist_index(__n);
 
       // Build free list in chunk.
@@ -771,7 +772,7 @@
     // __p is not permitted to be a null pointer.
     void
     deallocate(pointer __p, size_type __n)
-    { __underlying_alloc.deallocate(__p, __n * sizeof(_Tp)); }
+      { __underlying_alloc.deallocate(__p, __n * sizeof(_Tp)); }
 
     size_type
     max_size() const throw() { return size_t(-1) / sizeof(_Tp); }
@@ -784,7 +785,7 @@
   };
 
   template<typename _Alloc>
-    class __allocator<void, _Alloc>
+    struct __allocator<void, _Alloc>
     {
       typedef size_t      size_type;
       typedef ptrdiff_t   difference_type;


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]