replace int with size_t in stream methods #4706

pull kdomanski wants to merge 1 commits into bitcoin:master from kdomanski:2014_08_stream_size_t changing 1 files +4 −6
  1. kdomanski commented at 9:31 PM on August 15, 2014: contributor

    Thus the read(...) and write(...) methods of all stream classes now have identical parameter lists. This will bring these classes one step closer to a common interface.

  2. laanwj commented at 7:42 AM on August 18, 2014: member

    Looks good to me, although before merging it must be verified that we're not passing in numbers that are potentially negative anywhere. After this change that would result in an integer overflow or undefined behavior.

  3. kdomanski commented at 6:19 PM on August 18, 2014: contributor

    @laanwj I took a look and it seems that these methods are only ever used by various Serialize/Unserialize functions and methods. In some of them, the size parameter is acquired through sizeof operator. In other, the size is calculated in a trivial manner, or at least trivial anough to warrant usage of size_t in every other streamlike object's T.write(..) or T.read(..) method.

  4. replace int with size_t in stream methods
    Thus the read(...) and write(...) methods of all stream classes now have identical parameter lists.
    This will bring these classes one step closer to a common interface.
    8695a39350
  5. laanwj commented at 6:42 PM on August 18, 2014: member

    Ok thanks for checking.

    I'd prefer not use anything with virtual methods, though. Serialization is performance-critical, and having vtables (which are essentially function pointers) are known to make it easier to write exploits so may be worse from a security viewpoint.

  6. sipa commented at 6:46 PM on August 18, 2014: member

    Yes, I really want to avoid introducing runtime lookups for serialization. The effective amount of code is huge, and it only really works so well because the compiler can optimize pretty much everything away.

    Of course, I haven't benchmarked, and numbers may convince me otherwise.

  7. kdomanski closed this on Aug 18, 2014

  8. kdomanski reopened this on Aug 18, 2014

  9. sipa commented at 9:49 PM on August 18, 2014: member

    Untested ACK

  10. BitcoinPullTester commented at 10:31 PM on August 18, 2014: none

    Automatic sanity-testing: PASSED, see http://jenkins.bluematt.me/pull-tester/p4706_8695a39350cd9fd403c1bb1ca725535b591f82f9/ for binaries and test log. This test script verifies pulls every time they are updated. It, however, dies sometimes and fails to test properly. If you are waiting on a test, please check timestamps to verify that the test.log is moving at http://jenkins.bluematt.me/pull-tester/current/ Contact BlueMatt on freenode if something looks broken.

  11. jgarzik commented at 2:00 AM on August 19, 2014: contributor

    ut ACK

  12. laanwj added the label Improvement on Aug 19, 2014
  13. laanwj commented at 6:50 AM on August 21, 2014: member

    tested ACK

  14. laanwj merged this on Aug 21, 2014
  15. laanwj closed this on Aug 21, 2014

  16. laanwj referenced this in commit 56953925db on Aug 21, 2014
  17. kdomanski deleted the branch on Aug 21, 2014
  18. MarcoFalke locked this on Sep 8, 2021

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-17 09:15 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me