cli_reserve Subroutine

private subroutine cli_reserve(this)

Make room for one more entry, doubling the store when it is full.

Type Bound

cli_t

Arguments

Type IntentOptional Attributes Name
class(cli_t), intent(inout) :: this

Called by

proc~~cli_reserve~~CalledByGraph proc~cli_reserve cli_t%cli_reserve proc~cli_add_flag cli_t%cli_add_flag proc~cli_add_flag->proc~cli_reserve proc~cli_add_option cli_t%cli_add_option proc~cli_add_option->proc~cli_reserve proc~cli_add_positional cli_t%cli_add_positional proc~cli_add_positional->proc~cli_reserve

Variables

Type Visibility Attributes Name Initial
type(entry_t), private, allocatable :: bigger(:)
integer(kind=default_int), private :: capacity

Source Code

   subroutine cli_reserve(this)
      !! Make room for one more entry, doubling the store when it is full.
      class(cli_t), intent(inout) :: this

      type(entry_t), allocatable :: bigger(:)
      integer(default_int) :: capacity

      if (.not. allocated(this%entries)) then
         allocate (this%entries(INITIAL_CAPACITY))
         return
      end if
      capacity = size(this%entries, kind=default_int)
      if (this%count < capacity) return
      allocate (bigger(2_default_int*capacity))
      bigger(1:this%count) = this%entries(1:this%count)
      call move_alloc(bigger, this%entries)
   end subroutine cli_reserve