Skip to content
Browse files

more bulletproof clone

  • Loading branch information...
1 parent 433a926 commit 76c8b9aaabb817d99080356ee469bee31403556c @mental committed
Showing with 4 additions and 11 deletions.
  1. +4 −11 src/retrograph.c
View
15 src/retrograph.c
@@ -144,6 +144,7 @@ retrograph_vdu_t retrograph_new() {
}
void retrograph_clone(retrograph_vdu_t vdu, retrograph_vdu_t from_vdu) {
+ unsigned saved_refcount;
if (!vdu || vdu->error) {
return;
}
@@ -152,17 +153,9 @@ void retrograph_clone(retrograph_vdu_t vdu, retrograph_vdu_t from_vdu) {
vdu->error = from_vdu->error;
return;
}
- memcpy(vdu->vram, from_vdu->vram, sizeof(vdu->vram));
- memcpy(vdu->sprites, from_vdu->sprites, sizeof(vdu->sprites));
- memcpy(vdu->palette, from_vdu->palette, sizeof(vdu->palette));
- vdu->enable_bg = from_vdu->enable_bg;
- vdu->enable_sprites = from_vdu->enable_sprites;
- vdu->mode = from_vdu->mode;
- vdu->text_pattern_base = from_vdu->text_pattern_base;
- vdu->bg_pattern_base = from_vdu->bg_pattern_base;
- vdu->name_base = from_vdu->name_base;
- vdu->bg_scroll_x = from_vdu->bg_scroll_x;
- vdu->bg_scroll_y = from_vdu->bg_scroll_y;
+ saved_refcount = vdu->refcount;
+ memcpy(vdu, from_vdu, sizeof(struct retrograph_vdu_tag));
+ vdu->refcount = saved_refcount;
}
void retrograph_ref(retrograph_vdu_t vdu) {

0 comments on commit 76c8b9a

Please sign in to comment.
Something went wrong with that request. Please try again.