From a842c129ade033035fe656cabdaf86a24c59871b Mon Sep 17 00:00:00 2001 From: Jonathan Moore Liles Date: Tue, 10 Jun 2008 20:55:39 -0500 Subject: [PATCH] Cleanups. --- Timeline/Loggable.C | 22 ++++++++++++++++++---- Timeline/Loggable.H | 30 +----------------------------- 2 files changed, 19 insertions(+), 33 deletions(-) diff --git a/Timeline/Loggable.C b/Timeline/Loggable.C index f53704f..06ee142 100644 --- a/Timeline/Loggable.C +++ b/Timeline/Loggable.C @@ -22,7 +22,6 @@ #include #include -#include #include #include "util/file.h" @@ -31,8 +30,6 @@ using std::min; using std::max; -#include // for Fl::check() - FILE *Loggable::_fp; @@ -51,6 +48,24 @@ void *Loggable::_progress_callback_arg = NULL; +/** ensure that _loggables array is big enough for /n/ elements */ +void +Loggable::ensure_size ( size_t n ) +{ + if ( n > _loggables_size ) + { + size_t p = 0; + while ( ( (unsigned)1 << p ) < n ) ++p; + + size_t os = _loggables_size; + _loggables_size = 1 << p ; + + _loggables = (Loggable**) realloc( _loggables, sizeof( Loggable ** ) * _loggables_size ); + + memset( _loggables + os, 0, _loggables_size - os ); + } +} + /** Open the journal /filename/ and replay it, bringing the end state back into RAM */ bool Loggable::open ( const char *filename ) @@ -449,7 +464,6 @@ Loggable::compact ( void ) FATAL( "Could not write snapshot!" ); fseek( _fp, 0, SEEK_END ); -// _undo_index = 1; } /** Buffered sprintf wrapper */ diff --git a/Timeline/Loggable.H b/Timeline/Loggable.H index 06f950f..70f5536 100644 --- a/Timeline/Loggable.H +++ b/Timeline/Loggable.H @@ -69,8 +69,6 @@ class Loggable static int _log_id; static int _level; -/* static int _undo_index; */ - static off_t _undo_offset; static size_t _loggables_size; @@ -88,25 +86,10 @@ private: int _id; Log_Entry *_old_state; -// Log_Entry *_new_state; int _nest; - static void ensure_size ( size_t n ) - { - if ( n > _loggables_size ) - { - size_t p = 0; - while ( ( (unsigned)1 << p ) < n ) ++p; - - size_t os = _loggables_size; - _loggables_size = 1 << p ; - - _loggables = (Loggable**) realloc( _loggables, sizeof( Loggable ** ) * _loggables_size ); - - memset( _loggables + os, 0, _loggables_size - os ); - } - } + static void ensure_size ( size_t n ); void log_print( const Log_Entry *o, const Log_Entry *n ) const; static void log ( const char *fmt, ... ); @@ -152,8 +135,6 @@ public: static bool close ( void ); static void undo ( void ); -/* static int undo_index ( void ) { return _undo_index; } */ - static void compact ( void ); static @@ -199,8 +180,6 @@ public: void register_create ( const char *name, create_func *func ) { -// printf( "registering %s to %p\n", name, func ); - _class_map[ std::string( name ) ] = func; } @@ -226,15 +205,10 @@ protected: Loggable ( const Loggable & ) { init( true ); - /* FIXME: get a real id here!!! */ -// _id = 0; } public: -// virtual const char *class_name ( void ) const = 0; - - friend class Logger; }; @@ -276,6 +250,4 @@ public: } }; - - #include "Log_Entry.H"