Changeset 52 for trunk/src/xmlbuffer.c


Ignore:
Timestamp:
Feb 20, 2008, 11:05:02 AM (11 years ago)
Author:
cameron
Message:

Destructors

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/xmlbuffer.c

    r46 r52  
    5656}
    5757
     58U16_Buffer::~U16_Buffer() {
     59  simd_delete((SIMD_type *) x16hi);
     60  simd_delete((SIMD_type *) x16lo);
     61  simd_delete((SIMD_type *) x8data);
     62}
     63
    5864U16LE_Buffer::U16LE_Buffer(BytePack * src, int lgth, int BOM)
    5965        : U16_Buffer(src, lgth, BOM) {
     
    7884        x32lh = simd_new(8*total_blocks+LOOKAHEAD_PACKS);
    7985        x32ll = simd_new(8*total_blocks+LOOKAHEAD_PACKS);
     86}
     87
     88U32_Buffer::~U32_Buffer() {
     89  simd_delete((SIMD_type *) x32hh);
     90  simd_delete((SIMD_type *) x32hl);
     91  simd_delete((SIMD_type *) x32lh);
     92  simd_delete((SIMD_type *) x32ll);
     93  simd_delete((SIMD_type *) x8data);
    8094}
    8195
     
    259273XML_Buffer_Interface * XML_Buffer_Interface::BufferFactory(char* filename) {
    260274        int chars_read;
     275        struct stat fileinfo;
     276        stat(filename, &fileinfo);
     277        int buffer_packs = (fileinfo.st_size + BUFFER_PADDING + PACKSIZE - 1)/PACKSIZE;
     278        BytePack * src_data = simd_new(buffer_packs);
     279        unsigned char * bytedata = (unsigned char *) src_data;
    261280        FILE *infile;
    262281        infile = fopen(filename, "rb");
     
    265284                exit(-1);
    266285        }
    267        
    268         struct stat fileinfo;
    269         if(fstat(fileno(infile), &fileinfo)!=0) {
    270                 fprintf(stderr, "Error: cannot fstat %s for file size.\n", filename);
    271                 exit(-1);
    272         }
    273        
    274         int buffer_packs = (fileinfo.st_size + BUFFER_PADDING + PACKSIZE - 1)/PACKSIZE;
    275         BytePack * src_data = simd_new(buffer_packs);
    276         unsigned char * bytedata = (unsigned char *) src_data; 
    277        
    278         chars_read = fread(bytedata, 1, fileinfo.st_size, infile);
     286        chars_read = fread(bytedata, 1, fileinfo.st_size, infile);
    279287        if (chars_read != fileinfo.st_size) {
    280288                fprintf(stderr, "Error: fread returned %i characters, expecting %i.\n",
     
    282290                exit(-1);
    283291        }
    284        
    285292        // Install null sentinels.
    286293        memset(&bytedata[chars_read], 0, BUFFER_PADDING);
     
    323330}
    324331
     332
     333XML_Buffer_Interface::~XML_Buffer_Interface() {
     334  simd_delete(ByteBuffer);
     335}
     336
    325337int XML_Buffer_Interface::AvailableUnits(int pos) {
    326338        return (buffer_bytes/(int) code_unit_size) - pos;
Note: See TracChangeset for help on using the changeset viewer.