vec_grow Subroutine

private subroutine vec_grow(buf, mbuf, cap)

Arguments

Type IntentOptional Attributes Name
type(string_t), intent(inout), allocatable :: buf(:)
integer(kind=int64), intent(inout), allocatable :: mbuf(:)
integer, intent(inout) :: cap

Called by

proc~~vec_grow~~CalledByGraph proc~vec_grow vec_grow proc~vec_push_unique vec_push_unique proc~vec_push_unique->proc~vec_grow proc~gather_files_with_mask gather_files_with_mask proc~gather_files_with_mask->proc~vec_push_unique proc~push_file_with_mask push_file_with_mask proc~push_file_with_mask->proc~vec_push_unique proc~compute_watch_files_from_settings compute_watch_files_from_settings proc~compute_watch_files_from_settings->proc~gather_files_with_mask proc~compute_watch_files_from_settings->proc~push_file_with_mask proc~rebuild_watch_list rebuild_watch_list proc~rebuild_watch_list->proc~compute_watch_files_from_settings proc~handle_manifest_change handle_manifest_change proc~handle_manifest_change->proc~rebuild_watch_list proc~watcher_init watcher_t%watcher_init proc~watcher_init->proc~rebuild_watch_list proc~watcher_run watcher_t%watcher_run proc~watcher_run->proc~rebuild_watch_list proc~watcher_run->proc~handle_manifest_change

Source Code

   subroutine vec_grow(buf, mbuf, cap)
      type(string_t), allocatable, intent(inout) :: buf(:)
      integer(int64), allocatable, intent(inout) :: mbuf(:)
      integer, intent(inout) :: cap

      type(string_t), allocatable :: nb(:)
      integer(int64), allocatable :: nm(:)
      integer :: newcap, i

      newcap = max(16, cap + cap/2)
      allocate(nb(newcap), nm(newcap))
      do i = 1, cap
         nb(i)%s = buf(i)%s
         nm(i) = mbuf(i)
      end do
      call move_alloc(nb, buf)
      call move_alloc(nm, mbuf)
      cap = newcap
   end subroutine vec_grow