- do {
- if (num_msgs >= num_alloc) {
- if (num_alloc == 0) {
- num_alloc = 1024;
- msglist = malloc(num_alloc * sizeof(long));
- }
- else {
- num_alloc *= 2;
- msglist = realloc(msglist, num_alloc * sizeof(long));
- }
- }
- ctdl_readline(c, buf, sizeof(buf));
- msglist[num_msgs++] = atol(buf);
- } while (strcmp(buf, "000")); // this makes the last element a "0" terminator
+ while (ctdl_readline(c, buf, sizeof(buf)), strcmp(buf, "000")) {
+ long m = atol(buf);
+ array_append(msglist, &m);
+ }