Explicitly initialize prevector _union #14028

pull Empact wants to merge 1 commits into bitcoin:master from Empact:prevector-explicit-initialization changing 1 files +5 −5
  1. Empact commented at 9:24 AM on August 23, 2018: member

    No description provided.

  2. Empact commented at 9:24 AM on August 23, 2018: member

    Prompted by #13902

  3. fanquake added the label Refactoring on Aug 23, 2018
  4. Empact force-pushed on Aug 23, 2018
  5. Empact force-pushed on Aug 23, 2018
  6. in src/prevector.h:175 in bfa1d038f1 outdated
     174 | +            indirect.indirect = static_cast<char*>(malloc(((size_t)sizeof(T)) * _size));
     175 | +            assert(indirect.indirect);
     176 | +            indirect.capacity = _size;
     177 | +            _size += N + 1;
     178 | +            return indirect;
     179 | +        }
    


  7. DrahtBot commented at 11:29 AM on August 23, 2018: member

    <!--e57a25ab6845829454e8d69fc972939a-->No more conflicts as of last run.

  8. in src/prevector.h:267 in bfa1d038f1 outdated
     263 | @@ -248,32 +264,24 @@ class prevector {
     264 |  
     265 |      prevector() : _size(0), _union{{}} {}
     266 |  
     267 | -    explicit prevector(size_type n) : _size(0) {
     268 | -        resize(n);
     269 | +    explicit prevector(size_type n) : _size(n), _union{init_union()} {
    


    sipa commented at 4:15 PM on August 23, 2018:

    This is wrong. The _size field does not directly encode the size (see the comments above the class).


    Empact commented at 4:50 PM on August 23, 2018:

    init_union adds the N + 1 when appropriate.


    sipa commented at 4:55 PM on August 23, 2018:

    Yuck.


    Empact commented at 5:15 PM on August 23, 2018:

    Fair enough, moved it out of the initializer.

  9. Empact force-pushed on Aug 23, 2018
  10. Empact force-pushed on Aug 23, 2018
  11. Empact force-pushed on Aug 23, 2018
  12. Empact force-pushed on Aug 23, 2018
  13. practicalswift commented at 5:48 PM on August 23, 2018: contributor

    Concept ACK

    This fixes the compiler warning described in #13902

  14. Empact force-pushed on Aug 24, 2018
  15. Empact force-pushed on Aug 24, 2018
  16. Empact commented at 8:53 AM on August 24, 2018: member

    Pared the PR down to just explicitly initializing the _union

  17. practicalswift commented at 9:14 AM on August 24, 2018: contributor

    The updated version still fixes the compiler warning.

    ACK f955a50384ad53e6d1e89f373905ea8dabc46e93

  18. DrahtBot added the label Needs rebase on Aug 27, 2018
  19. Explicitly initialize prevector _union 1d9aa008d6
  20. Empact force-pushed on Aug 27, 2018
  21. Empact commented at 4:51 PM on August 27, 2018: member

    Rebased for #14030

  22. practicalswift commented at 4:57 PM on August 27, 2018: contributor

    utACK 1d9aa008d6e043c29c3c5b030a6d04278aea233b

  23. ken2812221 commented at 5:00 PM on August 27, 2018: contributor

    utACK 1d9aa008d6e043c29c3c5b030a6d04278aea233b

  24. DrahtBot removed the label Needs rebase on Aug 27, 2018
  25. laanwj merged this on Aug 29, 2018
  26. laanwj closed this on Aug 29, 2018

  27. laanwj referenced this in commit b0eb8f7ed4 on Aug 29, 2018
  28. Empact deleted the branch on Oct 9, 2018
  29. MarcoFalke referenced this in commit 3632143ebb on May 6, 2019
  30. sidhujag referenced this in commit e97c1bc114 on May 7, 2019
  31. Fuzzbawls referenced this in commit 8dfc4806f7 on May 19, 2020
  32. PastaPastaPasta referenced this in commit 8dc8d9c32e on Jun 27, 2021
  33. PastaPastaPasta referenced this in commit 3325df2cc1 on Jun 27, 2021
  34. PastaPastaPasta referenced this in commit afe9198916 on Jun 28, 2021
  35. PastaPastaPasta referenced this in commit cdbf7957d2 on Jun 28, 2021
  36. PastaPastaPasta referenced this in commit b480328fd0 on Jun 29, 2021
  37. PastaPastaPasta referenced this in commit 612b7e8fab on Jun 29, 2021
  38. PastaPastaPasta referenced this in commit 431ef8f783 on Jun 29, 2021
  39. PastaPastaPasta referenced this in commit aca3eb1b40 on Jun 29, 2021
  40. PastaPastaPasta referenced this in commit c62f8f6ef0 on Jun 29, 2021
  41. PastaPastaPasta referenced this in commit 493e0e8769 on Jun 29, 2021
  42. Munkybooty referenced this in commit 1cbd42663e on Jun 30, 2021
  43. PastaPastaPasta referenced this in commit 2d91eb7b77 on Jul 1, 2021
  44. PastaPastaPasta referenced this in commit 90f2117558 on Jul 1, 2021
  45. PastaPastaPasta referenced this in commit 7b1d8c5e53 on Jul 1, 2021
  46. PastaPastaPasta referenced this in commit bb27dde3cc on Jul 8, 2021
  47. PastaPastaPasta referenced this in commit 698ca44c98 on Jul 10, 2021
  48. 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-16 18:15 UTC

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