]> granicus.if.org Git - graphviz/commitdiff
rephrase some swapping code
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Thu, 22 Oct 2020 00:05:01 +0000 (17:05 -0700)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Thu, 29 Oct 2020 00:13:12 +0000 (17:13 -0700)
C allows you to assign structs in this way, so there's no need to use a more
confusing memcpy sequence.

lib/sfio/sfswap.c

index a607a5f04dfc8191b6aea7fbb626b6b493dfc818..0ed17c3afb9d6095a8a74f10ec2ba2c83ce2cb68 100644 (file)
@@ -77,9 +77,9 @@ Sfio_t *sfswap(Sfio_t * f1, Sfio_t * f2)
     f2flags = f2->flags;
 
     /* swap image and pool entries */
-    memcpy((void *) (&tmp), (void *) f1, sizeof(Sfio_t));
-    memcpy((void *) f1, (void *) f2, sizeof(Sfio_t));
-    memcpy((void *) f2, (void *) (&tmp), sizeof(Sfio_t));
+    tmp = *f1;
+    *f1 = *f2;
+    *f2 = tmp;
     if (f2pool >= 0)
        f1->pool->sf[f2pool] = f1;
     if (f1pool >= 0)