454 |
* structure and use that. Link it in in place of |
* structure and use that. Link it in in place of |
455 |
* the old line structure. |
* the old line structure. |
456 |
*/ |
*/ |
457 |
nlp = malloc(sizeof(LINE) + lp->len + deltaLen); |
nlp = xmalloc(sizeof(LINE) + lp->len + deltaLen); |
|
if (nlp == NULL) { |
|
|
bb_error_msg("cannot get memory for line"); |
|
|
return; |
|
|
} |
|
458 |
|
|
459 |
nlp->len = lp->len + deltaLen; |
nlp->len = lp->len + deltaLen; |
460 |
|
|
682 |
cc = 0; |
cc = 0; |
683 |
|
|
684 |
printf("\"%s\", ", file); |
printf("\"%s\", ", file); |
685 |
fflush(stdout); |
fflush_all(); |
686 |
|
|
687 |
do { |
do { |
688 |
cp = memchr(bufPtr, '\n', bufUsed); |
cp = memchr(bufPtr, '\n', bufUsed); |
708 |
|
|
709 |
if (bufUsed >= bufSize) { |
if (bufUsed >= bufSize) { |
710 |
len = (bufSize * 3) / 2; |
len = (bufSize * 3) / 2; |
711 |
cp = realloc(bufBase, len); |
cp = xrealloc(bufBase, len); |
|
if (cp == NULL) { |
|
|
bb_error_msg("no memory for buffer"); |
|
|
close(fd); |
|
|
return FALSE; |
|
|
} |
|
712 |
bufBase = cp; |
bufBase = cp; |
713 |
bufPtr = bufBase + bufUsed; |
bufPtr = bufBase + bufUsed; |
714 |
bufSize = len; |
bufSize = len; |
766 |
} |
} |
767 |
|
|
768 |
printf("\"%s\", ", file); |
printf("\"%s\", ", file); |
769 |
fflush(stdout); |
fflush_all(); |
770 |
|
|
771 |
lp = findLine(num1); |
lp = findLine(num1); |
772 |
if (lp == NULL) { |
if (lp == NULL) { |
863 |
return FALSE; |
return FALSE; |
864 |
} |
} |
865 |
|
|
866 |
newLp = malloc(sizeof(LINE) + len - 1); |
newLp = xmalloc(sizeof(LINE) + len - 1); |
|
if (newLp == NULL) { |
|
|
bb_error_msg("failed to allocate memory for line"); |
|
|
return FALSE; |
|
|
} |
|
867 |
|
|
868 |
memcpy(newLp->data, data, len); |
memcpy(newLp->data, data, len); |
869 |
newLp->len = len; |
newLp->len = len; |
938 |
* Returns the line number which matches, or 0 if there was no match |
* Returns the line number which matches, or 0 if there was no match |
939 |
* with an error printed. |
* with an error printed. |
940 |
*/ |
*/ |
941 |
static int searchLines(const char *str, int num1, int num2) |
static NOINLINE int searchLines(const char *str, int num1, int num2) |
942 |
{ |
{ |
943 |
const LINE *lp; |
const LINE *lp; |
944 |
int len; |
int len; |
970 |
lp = lp->next; |
lp = lp->next; |
971 |
} |
} |
972 |
|
|
973 |
bb_error_msg("cannot find string \"%s\"", str); |
bb_error_msg("can't find string \"%s\"", str); |
974 |
return 0; |
return 0; |
975 |
} |
} |
976 |
|
|