changeset 78b95c17a14c in /z/repo/m5
details: http://repo.m5sim.org/m5?cmd=changeset;node=78b95c17a14c
description:
        add a bit of style

diffstat:

2 files changed, 1 insertion(+), 3 deletions(-)
src/base/fast_alloc.cc |    1 -
src/base/fast_alloc.hh |    3 +--

diffs (208 lines):

diff -r 4c4b5dfc9944 -r 78b95c17a14c src/base/fast_alloc.cc
--- a/src/base/fast_alloc.cc    Fri Sep 26 09:37:21 2008 -0700
+++ b/src/base/fast_alloc.cc    Sat Sep 27 00:15:45 2008 -0700
@@ -34,7 +34,8 @@
  * by permission.
  */
 
-#include <assert.h>
+#include <cassert>
+
 #include "base/fast_alloc.hh"
 
 #if !NO_FAST_ALLOC
@@ -51,7 +52,8 @@
 unsigned FastAlloc::allocCount[Num_Buckets];
 #endif
 
-void *FastAlloc::moreStructs(int bucket)
+void *
+FastAlloc::moreStructs(int bucket)
 {
     assert(bucket > 0 && bucket < Num_Buckets);
 
@@ -71,14 +73,13 @@
     return (p + sz);
 }
 
-
 #if FAST_ALLOC_DEBUG
 
-#include <typeinfo>
+#include <iomanip>
 #include <iostream>
-#include <iomanip>
 #include <map>
 #include <string>
+#include <typeinfo>
 
 using namespace std;
 
@@ -96,7 +97,6 @@
     inUsePrev = prev;
     inUseNext = next;
 }
-
 
 // constructor: marks as in use, add to in-use list
 FastAlloc::FastAlloc()
@@ -131,7 +131,6 @@
     inUseNext->inUsePrev = inUsePrev;
 }
 
-
 // summarize in-use list
 void
 FastAlloc::dump_summary()
@@ -148,11 +147,8 @@
     cout << " count  type\n"
          << " -----  ----\n";
     for (mapiter = typemap.begin(); mapiter != typemap.end(); ++mapiter)
-    {
         cout << setw(6) << mapiter->second << "  " << mapiter->first << endl;
-    }
 }
-
 
 // show oldest n items on in-use list
 void
@@ -160,8 +156,7 @@
 {
     // sanity check: don't want to crash the debugger if you forget to
     // pass in a parameter
-    if (n < 0 || n > numInUse)
-    {
+    if (n < 0 || n > numInUse) {
         cout << "FastAlloc::dump_oldest: bad arg " << n
              << " (" << numInUse << " objects in use" << endl;
         return;
@@ -170,11 +165,8 @@
     for (FastAlloc *p = inUseHead.inUseNext;
          p != &inUseHead && n > 0;
          p = p->inUseNext, --n)
-    {
         cout << p << " " << typeid(*p).name() << endl;
-    }
 }
-
 
 //
 // C interfaces to FastAlloc::dump_summary() and FastAlloc::dump_oldest().
@@ -192,6 +184,6 @@
     FastAlloc::dump_oldest(n);
 }
 
-#endif
+#endif // FAST_ALLOC_DEBUG
 
 #endif // NO_FAST_ALLOC
diff -r 4c4b5dfc9944 -r 78b95c17a14c src/base/fast_alloc.hh
--- a/src/base/fast_alloc.hh    Fri Sep 26 09:37:21 2008 -0700
+++ b/src/base/fast_alloc.hh    Sat Sep 27 00:15:45 2008 -0700
@@ -34,10 +34,10 @@
  * by permission.
  */
 
-#ifndef __FAST_ALLOC_H__
-#define __FAST_ALLOC_H__
+#ifndef __BASE_FAST_ALLOC_HH__
+#define __BASE_FAST_ALLOC_HH__
 
-#include <stddef.h>
+#include <cstddef>
 
 // Fast structure allocator.  Designed for small objects that are
 // frequently allocated and deallocated.  This code is derived from the
@@ -68,14 +68,15 @@
 
 #if NO_FAST_ALLOC
 
-class FastAlloc {
+class FastAlloc
+{
 };
 
 #else
 
-class FastAlloc {
+class FastAlloc
+{
   public:
-
     static void *allocate(size_t);
     static void deallocate(void *, size_t);
 
@@ -84,7 +85,7 @@
 
 #if FAST_ALLOC_DEBUG
     FastAlloc();
-    FastAlloc(FastAlloc*,FastAlloc*);   // for inUseHead, see below
+    FastAlloc(FastAlloc *, FastAlloc *);   // for inUseHead, see below
     virtual ~FastAlloc();
 #else
     virtual ~FastAlloc() {}
@@ -139,16 +140,14 @@
 #endif
 };
 
-
-inline
-int FastAlloc::bucketFor(size_t sz)
+inline int
+FastAlloc::bucketFor(size_t sz)
 {
     return (sz + Alloc_Quantum - 1) >> Log2_Alloc_Quantum;
 }
 
-
-inline
-void *FastAlloc::allocate(size_t sz)
+inline void *
+FastAlloc::allocate(size_t sz)
 {
     int b;
     void *p;
@@ -171,14 +170,12 @@
     return p;
 }
 
-
-inline
-void FastAlloc::deallocate(void *p, size_t sz)
+inline void
+FastAlloc::deallocate(void *p, size_t sz)
 {
     int b;
 
-    if (sz > Max_Alloc_Size)
-    {
+    if (sz > Max_Alloc_Size) {
         ::delete [] (char *)p;
         return;
     }
@@ -191,20 +188,18 @@
 #endif
 }
 
-
-inline
-void *FastAlloc::operator new(size_t sz)
+inline void *
+FastAlloc::operator new(size_t sz)
 {
     return allocate(sz);
 }
 
-
-inline
-void FastAlloc::operator delete(void *p, size_t sz)
+inline void
+FastAlloc::operator delete(void *p, size_t sz)
 {
     deallocate(p, sz);
 }
 
 #endif // NO_FAST_ALLOC
 
-#endif // __FAST_ALLOC_H__
+#endif // __BASE_FAST_ALLOC_HH__
_______________________________________________
m5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/m5-dev

Reply via email to