* Creates a new subregion copy of fileobject. * Returns NULL if offset is greater than fileobject size. * Returns NULL on error. */
| 348 | * Returns NULL on error. |
| 349 | */ |
| 350 | static struct fileobject *malloc_fo_sub(const struct fileobject *old, |
| 351 | const size_t off) |
| 352 | { |
| 353 | struct fileobject *fo; |
| 354 | |
| 355 | if (!old || off > old->size) |
| 356 | return NULL; |
| 357 | |
| 358 | fo = malloc_fo(old->size - off); |
| 359 | if (!fo) |
| 360 | return NULL; |
| 361 | |
| 362 | memcpy(fo->data, old->data + off, fo->size); |
| 363 | |
| 364 | return fo; |
| 365 | } |
| 366 | |
| 367 | /* file helpers */ |
| 368 |
no test coverage detected