diff --git a/src/text.c.Text_enlarge b/src/text.c.Text_enlarge new file mode 100644 index 0000000000000000000000000000000000000000..b28c3b48705445129f7870c5d9e96e66371e0f9b --- /dev/null +++ b/src/text.c.Text_enlarge @@ -0,0 +1,90 @@ + +//~ static inline bool +//~ Text_enlarge (struct SH_Text * text, size_t size, + //~ struct text_segment ** last, struct SH_Error * error) +//~ { + //~ size_t new_size; + //~ struct text_segment * seg; + + //~ for (seg = text->data; seg->next != NULL; seg = seg->next); + + //~ if (size == SIZE_MAX) + //~ { + //~ ERROR1 ("Maximum length of SH_Text reached.\n"); + + //~ if (error != NULL) + //~ { + //~ error->type = DOMAIN_ERROR; + //~ } + + //~ return FALSE; + //~ } + //~ else if (SIZE_MAX - size < seg->size) + //~ { + //~ seg->next = malloc (sizeof (struct text_segment)); + + //~ if (seg->next == NULL) + //~ { + //~ ERROR1 ("Memory allocation for SH_Text data " + //~ "failed.\n"); + + //~ if (error != NULL) + //~ { + //~ error->type = ALLOCATION_FAILED; + //~ } + + //~ return FALSE; + //~ } + + //~ seg = seg->next; + //~ seg->length = 0; + //~ seg->size = 0; + //~ seg->text = NULL; + //~ seg->next = NULL; + //~ } + //~ else + //~ { + //~ size += seg->size; + //~ } + + + //~ /* if both operands were integers, + //~ * this operation would fail + //~ * as the division will behave like + //~ * calling floor in the first place. */ + //~ new_size = (size_t) ceilf ((float) size / (float) CHUNK_SIZE); + //~ if (new_size > (SIZE_MAX / (float) CHUNK_SIZE)) + //~ { + //~ new_size = size; + //~ } + //~ else + //~ { + //~ new_size *= CHUNK_SIZE; + //~ } + + //~ seg->text = realloc (seg->text, new_size * sizeof (char)); + + //~ if (errno == ENOMEM) + //~ { + //~ ERROR1 ("Memory allocation for SH_Text data failed.\n"); + + //~ if (error != NULL) + //~ { + //~ error->type = ALLOCATION_FAILED; + //~ } + + //~ return FALSE; + //~ } + + //~ seg->size = new_size; + + //~ *last = seg; + + //~ if (error != NULL) + //~ { + //~ error->type = SUCCESS; + //~ } + + //~ return TRUE; +//~ } +