Skip to content
Snippets Groups Projects
Commit 0530ad59 authored by Jonathan Schöbel's avatar Jonathan Schöbel
Browse files

unused function SH_Text_enlarge

The function SH_Text_enlarge was used as the common functionality of
SH_Text_append_string and SH_Text_append_text. It was first ported to
the new internal data structure, but then integrated into the function
SH_Text_append_string, because the function SH_Text_append_text doesn't
need it anymore and having the user calling it is now not as useful as
originally intended, both for the user and the library, so it shouldn't
be exposed. Also the method SH_Text_append_string is easier to
implement, if it is written as a single function.
Neithertheless it is commited here for future reference.
parent 51de2c6f
No related tags found
No related merge requests found
//~ 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;
//~ }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment