Unified · Split
| @@ -8,7 +8,6 @@ Object * · 7 unmodified lines | ||
| 8 | 8 | pdfarray(Pdf *pdf, Stream *s) |
| 9 | 9 | { |
| 10 | 10 | Object *o, *m; |
| 11 | − Object **a; | |
| 12 | 11 | int c, noel; |
| 13 | 12 | |
| 14 | 13 | o = calloc(1, sizeof(*o)); |
| @@ -30,13 +29,10 @@ pdfarray(Pdf *pdf, Stream *s) · 15 unmodified lines | ||
| 30 | 29 | continue; |
| 31 | 30 | } |
| 32 | 31 | |
| 33 | − if((a = realloc(o->array.e, (o->array.ne+1)*sizeof(Object*))) == nil){ | |
| 32 | + if(!arrayadd(o, m)){ | |
| 34 | 33 | pdfobjfree(m); |
| 35 | 34 | goto err; |
| 36 | 35 | } |
| 37 | − | |
| 38 | − o->array.e = a; | |
| 39 | − a[o->array.ne++] = m; | |
| 40 | 36 | } |
| 41 | 37 | |
| 42 | 38 | if(c != ']'){ |
| @@ -51,6 +47,19 @@ err: · 8 unmodified lines | ||
| 51 | 47 | return nil; |
| 52 | 48 | } |
| 53 | 49 | |
| 50 | +int | |
| 51 | +arrayadd(Object *arr, Object *o) | |
| 52 | +{ | |
| 53 | + Object **a; | |
| 54 | + a = realloc(arr->array.e, (arr->array.ne+1)*sizeof(Object*)); | |
| 55 | + if(a == nil) | |
| 56 | + return 0; | |
| 57 | + arr->array.e = a; | |
| 58 | + a[arr->array.ne] = o; | |
| 59 | + arr->array.ne += 1; | |
| 60 | + return 1; | |
| 61 | +} | |
| 62 | + | |
| 54 | 63 | int |
| 55 | 64 | arraylen(Object *o) |
| 56 | 65 | { |
| @@ -190,6 +190,7 @@ int isutf8(char *s, int len); · 189 unmodified lines | ||
| 190 | 190 | int arraylen(Object *o); |
| 191 | 191 | Object *arrayget(Object *o, int i); |
| 192 | 192 | int arrayint(Object *o, int i); |
| 193 | +int arrayadd(Object *a, Object *o); | |
| 193 | 194 | |
| 194 | 195 | Object *dictget(Object *o, char *name); |
| 195 | 196 | int dictint(Object *o, char *name); |