--- parser3/src/main/pa_string.C 2001/02/22 08:16:31 1.28 +++ parser3/src/main/pa_string.C 2001/02/22 12:43:55 1.31 @@ -1,5 +1,5 @@ /* - $Id: pa_string.C,v 1.28 2001/02/22 08:16:31 paf Exp $ + $Id: pa_string.C,v 1.31 2001/02/22 12:43:55 paf Exp $ */ #include @@ -24,7 +24,7 @@ String::String(Pool& apool) : void String::expand() { int new_chunk_count=last_chunk->count+last_chunk->count*CR_GROW_PERCENT/100; last_chunk=static_cast( - pool().malloc(sizeof(int)+sizeof(Chunk::Row)*new_chunk_count+sizeof(Chunk *))); + malloc(sizeof(int)+sizeof(Chunk::Row)*new_chunk_count+sizeof(Chunk *))); last_chunk->count=new_chunk_count; link_row->link=last_chunk; append_here=last_chunk->rows; @@ -58,7 +58,7 @@ String::String(const String& src) : // remaining rows into new_chunk int curr_chunk_rows=src_used_rows-head.count; Chunk *new_chunk=static_cast( - pool().malloc(sizeof(int)+sizeof(Chunk::Row)*curr_chunk_rows+sizeof(Chunk *))); + malloc(sizeof(int)+sizeof(Chunk::Row)*curr_chunk_rows+sizeof(Chunk *))); new_chunk->count=curr_chunk_rows; head.preallocated_link=new_chunk; append_here=link_row=&new_chunk->rows[new_chunk->count]; @@ -99,19 +99,19 @@ String& String::operator += (const Strin memcpy(append_here, src.head.rows, sizeof(Chunk::Row)*src_used_rows); append_here+=src_used_rows; } else { - // not all new rows don't fit into last chunk: shrinking it to used part, + // not all new rows fit into last chunk: shrinking it to used part, int used_rows=last_chunk->count-dst_free_rows; //int *countp=append_here link_row=&last_chunk->rows[last_chunk->count=used_rows]; // allocating only enough mem to fit src string rows // next append would allocate a new chunk last_chunk=static_cast( - pool().malloc(sizeof(int)+sizeof(Chunk::Row)*src_used_rows+sizeof(Chunk *))); + malloc(sizeof(int)+sizeof(Chunk::Row)*src_used_rows+sizeof(Chunk *))); last_chunk->count=src_used_rows; link_row->link=last_chunk; append_here=link_row=&last_chunk->rows[src_used_rows]; - Chunk *old_chunk=src.head.preallocated_link; + const Chunk *old_chunk=&src.head; Chunk::Row *new_rows=last_chunk->rows; int rows_left_to_copy=src_used_rows; while(true) { @@ -132,8 +132,8 @@ String& String::operator += (const Strin break; } } + link_row->link=0; } - link_row->link=0; fused_rows+=src_used_rows; fsize+=src.fsize; @@ -163,7 +163,7 @@ String& String::real_append(STRING_APPEN } char *String::cstr() const { - char *result=static_cast(pool().malloc(size()+1)); + char *result=static_cast(malloc(size()+1)); char *copy_here=result; const Chunk *chunk=&head;