1
0
mirror of https://github.com/pevans/erc-c.git synced 2024-11-23 23:32:45 +00:00

Let us fread into a segment offset

This commit is contained in:
Peter Evans 2018-01-03 15:16:30 -06:00
parent e7a404508e
commit 86dad129b6
2 changed files with 3 additions and 3 deletions

View File

@ -54,7 +54,7 @@ struct vm_segment {
};
extern int vm_segment_copy(vm_segment *, vm_segment *, size_t, size_t, size_t);
extern int vm_segment_fread(vm_segment *, FILE *, size_t);
extern int vm_segment_fread(vm_segment *, FILE *, size_t, size_t);
extern int vm_segment_read_map(vm_segment *, size_t, vm_segment_read_fn);
extern int vm_segment_set(vm_segment *, size_t, vm_8bit);
extern int vm_segment_write_map(vm_segment *, size_t, vm_segment_write_fn);

View File

@ -226,9 +226,9 @@ vm_segment_write_map(vm_segment *segment,
* for some reason, signal that and return an error.
*/
int
vm_segment_fread(vm_segment *segment, FILE *stream, size_t len)
vm_segment_fread(vm_segment *segment, FILE *stream, size_t offset, size_t len)
{
fread(segment->memory, sizeof(vm_8bit), len, stream);
fread(segment->memory + offset, sizeof(vm_8bit), len, stream);
// fread() may return zero in the case of an error, but it may
// return a positive non-zero number short of len; we can't quite