Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Text readText() {
- int size = BUFF_SIZE;
- int length = 0;
- int nlcount = 0;
- Sentence **text = malloc(size * sizeof(Sentence *));
- Sentence *sentence;
- do {
- sentence = readSentence();
- sentence->length != 1 ? fix_of_sentence(sentence) : sentence;
- if (sentence->str[0] == L'\n') {
- nlcount++;
- free(sentence);
- } else {
- nlcount = 0;
- text[length++] = sentence;
- if (length == size - 2) {
- size += MEM_STEP;
- text = realloc(text, size * sizeof(wchar_t *));
- if (text == NULL) {
- for (int i = 0; i < length; i++) {
- free(text[i]->str);
- free(text[i]);
- }
- Text txt;
- txt.size = size;
- txt.text = NULL;
- txt.length = length;
- return txt;
- }
- }
- }
- } while (nlcount < 2);
- Text txt;
- txt.size = size;
- txt.text = text;
- txt.length = length;
- return txt;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement