mirror of
https://github.com/pevans/erc-c.git
synced 2024-11-27 20:51:17 +00:00
Make encode/decode more testable with return codes
This commit is contained in:
parent
8009a33bd4
commit
1245ddec55
@ -34,6 +34,10 @@ apple2_dec_dos(vm_segment *dest, vm_segment *src)
|
||||
{
|
||||
int i, doff, tracklen;
|
||||
|
||||
if (dest == NULL || src == NULL) {
|
||||
return OK;
|
||||
}
|
||||
|
||||
for (i = 0, doff = 0; i < ENC_NUM_TRACKS; i++) {
|
||||
tracklen = apple2_dec_track(dest, src, doff, i);
|
||||
|
||||
@ -56,6 +60,15 @@ apple2_dec_dos(vm_segment *dest, vm_segment *src)
|
||||
int
|
||||
apple2_dec_nib(vm_segment *dest, vm_segment *src)
|
||||
{
|
||||
// It's "ok" if you pass in NULL params; the only time you ever
|
||||
// would is in testing, because we presume you are testing some
|
||||
// other aspect of the code there. (Good example: when your test is
|
||||
// not actually testing apple2_dec_nib, but something that calls
|
||||
// it.)
|
||||
if (dest == NULL || src == NULL) {
|
||||
return OK;
|
||||
}
|
||||
|
||||
return vm_segment_copy(dest, src, 0, 0, src->size);
|
||||
}
|
||||
|
||||
|
@ -25,6 +25,10 @@ apple2_enc_dos(vm_segment *src)
|
||||
vm_segment *dest;
|
||||
int i, doff = 0;
|
||||
|
||||
if (src == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// Use the nibbilized size for a 140k image file
|
||||
dest = vm_segment_create(_140K_NIB_);
|
||||
|
||||
@ -65,6 +69,11 @@ apple2_enc_nib(vm_segment *src)
|
||||
{
|
||||
vm_segment *dest;
|
||||
|
||||
// No src segment, no return data.
|
||||
if (src == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
dest = vm_segment_create(src->size);
|
||||
vm_segment_copy(dest, src, 0, 0, src->size);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user