34 lines
542 B
C
34 lines
542 B
C
Row *
|
|
b_getline(Row *r, int l) {
|
|
if (l == 1) return r;
|
|
if (r->n == NULL) return NULL;
|
|
return b_getline(r->n, l - 1);
|
|
}
|
|
|
|
Row *
|
|
b_insert(Row *r) {
|
|
Row *new = calloc(1, sizeof(Row));
|
|
new->n = r->n;
|
|
new->p = r;
|
|
r->n = new;
|
|
return new;
|
|
}
|
|
|
|
void
|
|
b_truncate(Row *row) {
|
|
Row *n = row->n;
|
|
row->n = NULL;
|
|
if (n != NULL) {
|
|
b_truncate(n);
|
|
free(n);
|
|
}
|
|
}
|
|
|
|
int
|
|
b_countlines(Row *row) {
|
|
int lines = 1;
|
|
for(; row->n != NULL; row = row->n) lines++;
|
|
return lines;
|
|
}
|
|
|