Cleanups.

This commit is contained in:
Jonathan Moore Liles 2008-06-10 20:55:39 -05:00
parent 957eed1f15
commit a842c129ad
2 changed files with 19 additions and 33 deletions

View File

@ -22,7 +22,6 @@
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <stdarg.h>
#include <string.h> #include <string.h>
#include "util/file.h" #include "util/file.h"
@ -31,8 +30,6 @@
using std::min; using std::min;
using std::max; using std::max;
#include <FL/Fl.H> // for Fl::check()
FILE *Loggable::_fp; 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 */ /** Open the journal /filename/ and replay it, bringing the end state back into RAM */
bool bool
Loggable::open ( const char *filename ) Loggable::open ( const char *filename )
@ -449,7 +464,6 @@ Loggable::compact ( void )
FATAL( "Could not write snapshot!" ); FATAL( "Could not write snapshot!" );
fseek( _fp, 0, SEEK_END ); fseek( _fp, 0, SEEK_END );
// _undo_index = 1;
} }
/** Buffered sprintf wrapper */ /** Buffered sprintf wrapper */

View File

@ -69,8 +69,6 @@ class Loggable
static int _log_id; static int _log_id;
static int _level; static int _level;
/* static int _undo_index; */
static off_t _undo_offset; static off_t _undo_offset;
static size_t _loggables_size; static size_t _loggables_size;
@ -88,25 +86,10 @@ private:
int _id; int _id;
Log_Entry *_old_state; Log_Entry *_old_state;
// Log_Entry *_new_state;
int _nest; int _nest;
static void ensure_size ( size_t n ) 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 );
}
}
void log_print( const Log_Entry *o, const Log_Entry *n ) const; void log_print( const Log_Entry *o, const Log_Entry *n ) const;
static void log ( const char *fmt, ... ); static void log ( const char *fmt, ... );
@ -152,8 +135,6 @@ public:
static bool close ( void ); static bool close ( void );
static void undo ( void ); static void undo ( void );
/* static int undo_index ( void ) { return _undo_index; } */
static void compact ( void ); static void compact ( void );
static static
@ -199,8 +180,6 @@ public:
void void
register_create ( const char *name, create_func *func ) register_create ( const char *name, create_func *func )
{ {
// printf( "registering %s to %p\n", name, func );
_class_map[ std::string( name ) ] = func; _class_map[ std::string( name ) ] = func;
} }
@ -226,15 +205,10 @@ protected:
Loggable ( const Loggable & ) Loggable ( const Loggable & )
{ {
init( true ); init( true );
/* FIXME: get a real id here!!! */
// _id = 0;
} }
public: public:
// virtual const char *class_name ( void ) const = 0;
friend class Logger; friend class Logger;
}; };
@ -276,6 +250,4 @@ public:
} }
}; };
#include "Log_Entry.H" #include "Log_Entry.H"