Menu

#5732 Use unique_ptr in layout code

Fixed
Dan Eble
Enhancement
2020-02-06
2020-02-03
Dan Eble
No

Use std::unique_ptr instead of manually managed raw pointers.

I suggest beginning the review in Accidental_placement_entry. The
algorithm in stagger_apes () took me the most time to come to term
with. With unique_ptr, it's much easier to be confident that there
isn't a memory leak there.

unique_ptr deletes its object when it goes out of scope. Transferring
ownership of the object to another instance of unique_ptr is done with
std::move(). A unique_ptr can not be copied, but one can get an alias
(a raw pointer) from it with p.get().

Using unique_ptr makes the flower junk_pointers() function
unnecessary. I can't remove junk_pointers() yet because MIDI code
still uses it, and I don't want to wade into that high water now.

I'm aware that some lines are longer than 80 characters. I plan to
try clang-format after Han-Wen's config file makes it through the
countdown.

https://codereview.appspot.com/573500043

Discussion

  • Anonymous

    Anonymous - 2020-02-03
    • Description has changed:

    Diff:

    
    
    • Needs: -->
    • Patch: new --> review
     
  • Anonymous

    Anonymous - 2020-02-03

    Passes make, make check and a full make doc

     
  • Anonymous

    Anonymous - 2020-02-04
    • Patch: review --> countdown
     
  • Anonymous

    Anonymous - 2020-02-04

    Patch on countdown for Feb 6th.

     
  • Anonymous

    Anonymous - 2020-02-06
    • Patch: countdown --> push
     
  • Anonymous

    Anonymous - 2020-02-06

    Patch counted down - please push.

     
  • Dan Eble

    Dan Eble - 2020-02-06
    • labels: --> Fixed_2_21_0
    • status: Started --> Fixed
    • Patch: push -->
     
  • Dan Eble

    Dan Eble - 2020-02-06
    commit 011a4593fcc6450e9cb1fc0fff9bc3e5b1395a9b
    Author: Dan Eble <nine.fierce.ballads@gmail.com>
    Date:   Sun Feb 2 21:42:06 2020 -0500
    
        Issue 5732/4: Use unique_ptr for Slur_configuration
    
    commit e42552f5fac039a73018d2fcb4a11f0fc1a7b9f7
    Author: Dan Eble <nine.fierce.ballads@gmail.com>
    Date:   Sun Feb 2 21:50:50 2020 -0500
    
        Issue 5732/3: Use unique_ptr in Bracket_nesting_group
    
    commit 92590f43038b346a8fb6b1901cdf92f2e193a327
    Author: Dan Eble <nine.fierce.ballads@gmail.com>
    Date:   Sun Feb 2 22:05:42 2020 -0500
    
        Issue 5732/2: Use unique_ptr for Beam_configuration
    
    commit d317c9675c6ff7acc1c5b399754e95a3103f8b2e
    Author: Dan Eble <nine.fierce.ballads@gmail.com>
    Date:   Mon Feb 3 11:19:05 2020 -0500
    
        Issue 5732/1: Use unique_ptr for Accidental_placement_entry