| 603 | } |
| 604 | |
| 605 | redisReader *redisReaderCreateWithFunctions(redisReplyObjectFunctions *fn) { |
| 606 | redisReader *r; |
| 607 | |
| 608 | r = hi_calloc(1,sizeof(redisReader)); |
| 609 | if (r == NULL) |
| 610 | return NULL; |
| 611 | |
| 612 | r->buf = hi_sdsempty(); |
| 613 | if (r->buf == NULL) |
| 614 | goto oom; |
| 615 | |
| 616 | r->task = hi_calloc(REDIS_READER_STACK_SIZE, sizeof(*r->task)); |
| 617 | if (r->task == NULL) |
| 618 | goto oom; |
| 619 | |
| 620 | for (; r->tasks < REDIS_READER_STACK_SIZE; r->tasks++) { |
| 621 | r->task[r->tasks] = hi_calloc(1, sizeof(**r->task)); |
| 622 | if (r->task[r->tasks] == NULL) |
| 623 | goto oom; |
| 624 | } |
| 625 | |
| 626 | r->fn = fn; |
| 627 | r->maxbuf = REDIS_READER_MAX_BUF; |
| 628 | r->maxelements = REDIS_READER_MAX_ARRAY_ELEMENTS; |
| 629 | r->ridx = -1; |
| 630 | |
| 631 | return r; |
| 632 | oom: |
| 633 | redisReaderFree(r); |
| 634 | return NULL; |
| 635 | } |
| 636 | |
| 637 | void redisReaderFree(redisReader *r) { |
| 638 | if (r == NULL) |
no test coverage detected