Branch Coverage

src/pdfmake_types.c
Criterion Covered Total %
branch 158 282 56.0


line true false branch
52 9186 0 if (!arena || !bytes) {
0 9186 if (!arena || !bytes) {
58 0 9186 if (len == 0 && bytes[0] != '\0') {
0 0 if (len == 0 && bytes[0] != '\0') {
67 1741 0 return pdfmake_name(arena, cstr, cstr ? strlen(cstr) : 0);
79 1549 0 if (!arena || !bytes || len == 0) {
1549 0 if (!arena || !bytes || len == 0) {
2 1547 if (!arena || !bytes || len == 0) {
88 0 1547 if (!dup) {
104 776 0 return pdfmake_str(arena, cstr, cstr ? strlen(cstr) : 0);
137 0 2020 if (!arena) {
143 0 2020 if (!arr) {
149 0 2020 if (!arr->items) {
162 15913 0 if (!arena || !arr_obj || arr_obj->kind != PDFMAKE_ARRAY || !arr_obj->as.arr) {
15913 0 if (!arena || !arr_obj || arr_obj->kind != PDFMAKE_ARRAY || !arr_obj->as.arr) {
15913 0 if (!arena || !arr_obj || arr_obj->kind != PDFMAKE_ARRAY || !arr_obj->as.arr) {
0 15913 if (!arena || !arr_obj || arr_obj->kind != PDFMAKE_ARRAY || !arr_obj->as.arr) {
169 560 15353 if (arr->len >= arr->cap) {
172 0 560 if (!new_items) return 0;
185 8875 0 if (!arr_obj || arr_obj->kind != PDFMAKE_ARRAY || !arr_obj->as.arr) {
8875 0 if (!arr_obj || arr_obj->kind != PDFMAKE_ARRAY || !arr_obj->as.arr) {
0 8875 if (!arr_obj || arr_obj->kind != PDFMAKE_ARRAY || !arr_obj->as.arr) {
190 1 8874 if (index >= arr->len) return NULL;
197 0 0 if (!arr_obj || arr_obj->kind != PDFMAKE_ARRAY || !arr_obj->as.arr) {
0 0 if (!arr_obj || arr_obj->kind != PDFMAKE_ARRAY || !arr_obj->as.arr) {
0 0 if (!arr_obj || arr_obj->kind != PDFMAKE_ARRAY || !arr_obj->as.arr) {
202 0 0 if (index >= arr->len) return 0;
209 827 0 if (!arr_obj || arr_obj->kind != PDFMAKE_ARRAY || !arr_obj->as.arr) {
827 0 if (!arr_obj || arr_obj->kind != PDFMAKE_ARRAY || !arr_obj->as.arr) {
0 827 if (!arr_obj || arr_obj->kind != PDFMAKE_ARRAY || !arr_obj->as.arr) {
233 20398 0 if (!dict->entries || dict->cap == 0) return 0;
0 20398 if (!dict->entries || dict->cap == 0) return 0;
239 21914 0 for (i = 0; i < dict->cap; i++) {
242 16352 5562 if (e->key == 0 && !e->deleted) {
16225 127 if (e->key == 0 && !e->deleted) {
244 111 16114 if (first_tombstone != (size_t)-1) {
250 127 5562 if (e->deleted) {
252 111 16 if (first_tombstone == (size_t)-1) {
255 4173 1389 } else if (e->key == key) {
265 0 0 return first_tombstone != (size_t)-1 ? first_tombstone : 0;
274 0 28 if (new_cap == 0) new_cap = DICT_INIT_CAP;
277 0 28 if (!new_entries) return 0;
281 576 28 for (i = 0; i < dict->cap; i++) {
283 396 180 if (e->key != 0 && !e->deleted) {
396 0 if (e->key != 0 && !e->deleted) {
285 1 396 while (new_entries[idx].key != 0) {
304 0 4423 if (!arena) {
310 0 4423 if (!dict) {
316 0 4423 if (!dict->entries) {
333 13650 0 if (!arena || !dict_obj || dict_obj->kind != PDFMAKE_DICT || !dict_obj->as.dict || key == 0) {
13650 0 if (!arena || !dict_obj || dict_obj->kind != PDFMAKE_DICT || !dict_obj->as.dict || key == 0) {
13650 0 if (!arena || !dict_obj || dict_obj->kind != PDFMAKE_DICT || !dict_obj->as.dict || key == 0) {
13650 0 if (!arena || !dict_obj || dict_obj->kind != PDFMAKE_DICT || !dict_obj->as.dict || key == 0) {
0 13650 if (!arena || !dict_obj || dict_obj->kind != PDFMAKE_DICT || !dict_obj->as.dict || key == 0) {
340 28 13622 if ((dict->len + dict->tombstones + 1) * DICT_LOAD_FACTOR_DEN > dict->cap * DICT_LOAD_FACTOR_NUM) {
341 0 28 if (!dict_grow(arena, dict)) return 0;
346 203 13447 if (found) {
351 51 13396 if (dict->entries[idx].deleted) {
368 6591 0 if (!dict_obj || dict_obj->kind != PDFMAKE_DICT || !dict_obj->as.dict || key == 0) {
6591 0 if (!dict_obj || dict_obj->kind != PDFMAKE_DICT || !dict_obj->as.dict || key == 0) {
6591 0 if (!dict_obj || dict_obj->kind != PDFMAKE_DICT || !dict_obj->as.dict || key == 0) {
0 6591 if (!dict_obj || dict_obj->kind != PDFMAKE_DICT || !dict_obj->as.dict || key == 0) {
375 3865 2726 if (found) {
389 157 0 if (!dict_obj || dict_obj->kind != PDFMAKE_DICT || !dict_obj->as.dict || key == 0) {
157 0 if (!dict_obj || dict_obj->kind != PDFMAKE_DICT || !dict_obj->as.dict || key == 0) {
157 0 if (!dict_obj || dict_obj->kind != PDFMAKE_DICT || !dict_obj->as.dict || key == 0) {
0 157 if (!dict_obj || dict_obj->kind != PDFMAKE_DICT || !dict_obj->as.dict || key == 0) {
396 105 52 if (found) {
407 3 0 if (!dict_obj || dict_obj->kind != PDFMAKE_DICT || !dict_obj->as.dict) {
3 0 if (!dict_obj || dict_obj->kind != PDFMAKE_DICT || !dict_obj->as.dict) {
0 3 if (!dict_obj || dict_obj->kind != PDFMAKE_DICT || !dict_obj->as.dict) {
432 2446 0 if (!iter || !iter->dict_obj || iter->dict_obj->kind != PDFMAKE_DICT || !iter->dict_obj->as.dict) {
2446 0 if (!iter || !iter->dict_obj || iter->dict_obj->kind != PDFMAKE_DICT || !iter->dict_obj->as.dict) {
2446 0 if (!iter || !iter->dict_obj || iter->dict_obj->kind != PDFMAKE_DICT || !iter->dict_obj->as.dict) {
0 2446 if (!iter || !iter->dict_obj || iter->dict_obj->kind != PDFMAKE_DICT || !iter->dict_obj->as.dict) {
445 39136 2446 for (i = 0; i < dict->cap; i++) {
447 11416 27720 if (e->key != 0 && !e->deleted) {
11416 0 if (e->key != 0 && !e->deleted) {
448 5708 5708 if (e->order >= iter->index && e->order < best_order) {
2313 3395 if (e->order >= iter->index && e->order < best_order) {
455 613 1833 if (best_idx == (size_t)-1) {
475 0 580 if (!arena) {
481 0 580 if (!stream) {
488 580 0 if (dict.as.dict) {
503 528 0 if (!arena || !stream_obj || stream_obj->kind != PDFMAKE_STREAM || !stream_obj->as.stream) {
528 0 if (!arena || !stream_obj || stream_obj->kind != PDFMAKE_STREAM || !stream_obj->as.stream) {
528 0 if (!arena || !stream_obj || stream_obj->kind != PDFMAKE_STREAM || !stream_obj->as.stream) {
0 528 if (!arena || !stream_obj || stream_obj->kind != PDFMAKE_STREAM || !stream_obj->as.stream) {
509 528 0 if (data && len > 0) {
510 18 if (data && len > 0) {
511 0 510 if (!dup) return 0;
523 24 0 if (!stream_obj || stream_obj->kind != PDFMAKE_STREAM || !stream_obj->as.stream) {
24 0 if (!stream_obj || stream_obj->kind != PDFMAKE_STREAM || !stream_obj->as.stream) {
0 24 if (!stream_obj || stream_obj->kind != PDFMAKE_STREAM || !stream_obj->as.stream) {
534 0 0 if (!arena || !stream_obj || stream_obj->kind != PDFMAKE_STREAM || !stream_obj->as.stream) {
0 0 if (!arena || !stream_obj || stream_obj->kind != PDFMAKE_STREAM || !stream_obj->as.stream) {
0 0 if (!arena || !stream_obj || stream_obj->kind != PDFMAKE_STREAM || !stream_obj->as.stream) {
0 0 if (!arena || !stream_obj || stream_obj->kind != PDFMAKE_STREAM || !stream_obj->as.stream) {
539 0 0 if (!stream->dict) return 0;
543 0 0 if (filter_key == 0) return 0;
548 0 0 if (!pdfmake_dict_set(arena, &dict_obj, filter_key, filter_name)) {
562 2 0 return obj && obj->kind == PDFMAKE_NULL;
1 1 return obj && obj->kind == PDFMAKE_NULL;
566 2 0 return obj && obj->kind == PDFMAKE_BOOL;
1 1 return obj && obj->kind == PDFMAKE_BOOL;
570 2 0 return obj && obj->kind == PDFMAKE_INT;
1 1 return obj && obj->kind == PDFMAKE_INT;
574 2 0 return obj && obj->kind == PDFMAKE_REAL;
1 1 return obj && obj->kind == PDFMAKE_REAL;
578 3 0 return obj && (obj->kind == PDFMAKE_INT || obj->kind == PDFMAKE_REAL);
2 1 return obj && (obj->kind == PDFMAKE_INT || obj->kind == PDFMAKE_REAL);
1 1 return obj && (obj->kind == PDFMAKE_INT || obj->kind == PDFMAKE_REAL);
582 2 0 return obj && obj->kind == PDFMAKE_NAME;
1 1 return obj && obj->kind == PDFMAKE_NAME;
586 3 0 return obj && obj->kind == PDFMAKE_STR;
2 1 return obj && obj->kind == PDFMAKE_STR;
590 3 0 return obj && obj->kind == PDFMAKE_ARRAY;
1 2 return obj && obj->kind == PDFMAKE_ARRAY;
594 4 0 return obj && obj->kind == PDFMAKE_DICT;
1 3 return obj && obj->kind == PDFMAKE_DICT;
598 1 0 return obj && obj->kind == PDFMAKE_STREAM;
1 0 return obj && obj->kind == PDFMAKE_STREAM;
602 1 0 return obj && obj->kind == PDFMAKE_REF;
1 0 return obj && obj->kind == PDFMAKE_REF;
606 2 0 return (obj && obj->kind == PDFMAKE_BOOL) ? (int)obj->as.i : 0;
2 0 return (obj && obj->kind == PDFMAKE_BOOL) ? (int)obj->as.i : 0;
610 0 7 if (!obj) return 0;
611 7 0 if (obj->kind == PDFMAKE_INT) return obj->as.i;
612 0 0 if (obj->kind == PDFMAKE_REAL) return (int64_t)obj->as.r;
617 0 14 if (!obj) return 0.0;
618 1 13 if (obj->kind == PDFMAKE_REAL) return obj->as.r;
619 13 0 if (obj->kind == PDFMAKE_INT) return (double)obj->as.i;
628 321 0 if (!arena || !obj || obj->kind != PDFMAKE_NAME) return NULL;
321 0 if (!arena || !obj || obj->kind != PDFMAKE_NAME) return NULL;
0 321 if (!arena || !obj || obj->kind != PDFMAKE_NAME) return NULL;
633 66 0 if (!obj || obj->kind != PDFMAKE_STR) {
0 66 if (!obj || obj->kind != PDFMAKE_STR) {
634 0 0 if (len_out) *len_out = 0;
637 66 0 if (len_out) *len_out = obj->as.str.len;
642 0 0 return (obj && obj->kind == PDFMAKE_STR) ? obj->as.str.hex : 0;
0 0 return (obj && obj->kind == PDFMAKE_STR) ? obj->as.str.hex : 0;