{
DWord dw_cnt;
DWord dw_line;
+ DWord dw_sections;
LibEditText_LineSection *p_section;
LibEditText_LineSection *p_nowsec;
LibEditText_LineInfo *p_line;
dw_line = (p_tinfo->dw_maxline * dw_cnt) / p_tinfo->dw_sections;
p_nowsec = (p_section + dw_cnt);
- if( INVALID_LINE != p_nowsec->dw_linfoid ) {
- p_nowsec->dw_linfoid = INVALID_LINE - 1;
- p_nowsec->dw_line = dw_line;
- }
+ p_nowsec->dw_linfoid = INVALID_LINE - 1;
+ p_nowsec->dw_line = dw_line;
}
p_line = LINFO(p_tinfo, p_tinfo->dw_line_start);
}
p_nowsec = p_section;
+ dw_sections = p_tinfo->dw_sections;
for( dw_line = 0; dw_line < p_tinfo->dw_maxline; dw_line++ ) {
while( dw_line == p_nowsec->dw_line ) {
p_nowsec->dw_linfoid = p_line->dw_id;
p_nowsec++;
+ if( 0 == --dw_sections)
+ { goto goto_LibEditText_Section_ConstractSection_post; }
}
p_line = LINFO(p_tinfo, p_line->dw_next);
}
+goto_LibEditText_Section_ConstractSection_post:
+
return 0x00;
}
LibEditText_Section_InitSection(
LibEditText_TextInfo *p_tinfo )
{
+ int i_tmp;
int i_result = 0x00;
- DWord dw_cnt;
+ DWord dw_cnt;
+ DWord dw_req_sections;
+ DWord dw_allocsections;
+ DWord dw_stepsection;
LibEditText_LineSection *p_section;
LibEditText_LineSection *p_nowsec;
assert( NULL != p_tinfo );
+ p_tinfo->dw_bufsections = DRD64_LIBEDITTEXT_DEFAULT_ALLOCSECTIONS;
+ p_tinfo->dw_sections = DRD64_LIBEDITTEXT_DEFAULT_LINESECTIONS;
+ p_tinfo->dw_sect_steps = DRD64_LIBEDITTEXT_DEFAULT_SECTIONSTEPS;
+
+ dw_req_sections = p_tinfo->dw_maxline / DRD64_LIBEDITTEXT_DEFAULT_SECTIONSTEPS;
+
+ if( DRD64_LIBEDITTEXT_DEFAULT_ALLOCSECTIONS < dw_req_sections ) {
+ dw_allocsections = DRD64_LIBEDITTEXT_DEFAULT_ALLOCSECTIONS * 2;
+ dw_stepsection = DRD64_LIBEDITTEXT_DEFAULT_SECTIONSTEPS * 2;
+ for( i_tmp = 0; i_tmp < DRD64_LIBEDITTEXT_DEFAULT_REMAIN_SECPOWS; i_tmp++ ) {
+ if( dw_req_sections < dw_allocsections ) { break; }
+ dw_allocsections *= 2;
+ dw_stepsection *= 2;
+ }
+ if( DRD64_LIBEDITTEXT_DEFAULT_REMAIN_SECPOWS == i_tmp ) { return -0x01; }
+
+ p_tinfo->dw_bufsections = dw_allocsections;
+ p_tinfo->dw_sections = dw_req_sections;
+ p_tinfo->dw_sect_steps = dw_stepsection;
+ }
+ else if( DRD64_LIBEDITTEXT_DEFAULT_LINESECTIONS < dw_req_sections ) {
+ p_tinfo->dw_sections = dw_req_sections;
+ }
+
p_section = (LibEditText_LineSection *)malloc(
sizeof( LibEditText_LineSection )
- * DRD64_LIBEDITTEXT_DEFAULT_ALLOCSECTIONS );
+ * p_tinfo->dw_bufsections );
if( NULL == p_section ) {
return -0x01;
}
memset( p_section, 0x00, sizeof( LibEditText_LineSection )
- * DRD64_LIBEDITTEXT_DEFAULT_ALLOCSECTIONS );
+ * p_tinfo->dw_bufsections );
p_nowsec = p_section;
- for( dw_cnt = 0; dw_cnt < DRD64_LIBEDITTEXT_DEFAULT_LINESECTIONS; dw_cnt++ ) {
+ for( dw_cnt = 0; dw_cnt < p_tinfo->dw_bufsections; dw_cnt++ ) {
p_nowsec->dw_line = 0;
p_nowsec->dw_linfoid = INVALID_LINE;
}
p_tinfo->p_section = p_section;
- p_tinfo->dw_bufsections = DRD64_LIBEDITTEXT_DEFAULT_ALLOCSECTIONS
- - DRD64_LIBEDITTEXT_DEFAULT_LINESECTIONS;
- p_tinfo->dw_sections = DRD64_LIBEDITTEXT_DEFAULT_LINESECTIONS;
- p_tinfo->dw_sect_steps = DRD64_LIBEDITTEXT_DEFAULT_SECTIONSTEPS;
return i_result;
}