Changeset 184 for trunk/src/symtab.c


Ignore:
Timestamp:
Jul 20, 2008, 6:39:35 AM (11 years ago)
Author:
cameron
Message:

Create stringpool.h

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/symtab.c

    r179 r184  
    11#include "symtab.h"
    22
    3 const int INIT_STRINGPOOL_SIZE = 4096;
    43
    54inline bool bit_test(unsigned char * bit_Map, int codepoint) {
     
    219218int Symbol_Table::Insert_Name(char * name, int lgth) {
    220219//      char * s = copy_name(name,lgth);
    221         char * s = pool->Insert(name,lgth);
     220        char * s = pool.Insert(name,lgth);
    222221        UTF8NameMap[s]=++(globalNameCount);
    223222        Name_Data name_data;
     
    302301        #endif
    303302//              char * s = copy_name(name,lgth);
    304                 char * s = pool->Insert(name,lgth);
     303                char * s = pool.Insert(name,lgth);
    305304                UTF8NameMap[s]=++(globalNameCount);
    306305                nameID = globalNameCount;
     
    366365        #endif
    367366//              char * s = copy_name(name,lgth);
    368                 char * s = pool->Insert(nmtoken,lgth);
     367                char * s = pool.Insert(nmtoken,lgth);
    369368                UTF8NmtokenMap[s]=++(globalNmtokenCount);
    370369                nmtokenID = globalNmtokenCount;
     
    456455//              UTF8NameTable.push_back(predefined[i]);
    457456        }*/
    458         pool = new StringPool;
    459 }
    460 
    461 
    462 StringPool::StringPool() {
    463        buffer_capacity = INIT_STRINGPOOL_SIZE;
    464        buffer_space_used = 0;
    465        pool_buffers.push_back(new char [buffer_capacity]);
    466 }
    467 
    468 StringPool::~StringPool() {
    469        vector<char * >::iterator i;
    470        for (i = pool_buffers.begin(); i != pool_buffers.end(); i++) {
    471                delete [] *i;
    472        }
    473 }
    474 
    475 char * StringPool::Insert(char * s, int lgth) {
    476        while (lgth + buffer_space_used >= buffer_capacity) {
    477                buffer_capacity *= 2;
    478                pool_buffers.push_back(new char [buffer_capacity]);
    479                buffer_space_used = 0;
    480        }
    481        char * insertion_ptr = &pool_buffers.back()[buffer_space_used];
    482        memcpy(insertion_ptr, s, lgth);
    483        insertion_ptr[lgth] = '\0';
    484        buffer_space_used += lgth + 1;
    485        return insertion_ptr;
    486 }
    487 
    488 
    489 
     457}
     458
     459
     460
     461
Note: See TracChangeset for help on using the changeset viewer.