init_fingerprints Subroutine

public subroutine init_fingerprints(files, fp_prev, fp_now, changed_idx)

Initialize fingerprint arrays for a watch list.

Allocates fp_prev, fp_now, and changed_idx to match the size of files. Initial fingerprints are computed once and copied into fp_now.

Arguments

Type IntentOptional Attributes Name
type(string_t), intent(in), allocatable :: files(:)
integer(kind=int64), intent(inout), allocatable :: fp_prev(:)
integer(kind=int64), intent(inout), allocatable :: fp_now(:)
integer, intent(inout), allocatable :: changed_idx(:)

Calls

proc~~init_fingerprints~~CallsGraph proc~init_fingerprints init_fingerprints proc~file_fingerprint file_fingerprint proc~init_fingerprints->proc~file_fingerprint proc~hash_block hash_block proc~file_fingerprint->proc~hash_block proc~fnv1a_mix_i64 fnv1a_mix_i64 proc~hash_block->proc~fnv1a_mix_i64

Called by

proc~~init_fingerprints~~CalledByGraph proc~init_fingerprints init_fingerprints proc~rebuild_watch_list rebuild_watch_list proc~rebuild_watch_list->proc~init_fingerprints 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 init_fingerprints(files, fp_prev, fp_now, changed_idx)
      type(string_t), allocatable, intent(in) :: files(:)
      integer(int64), allocatable, intent(inout) :: fp_prev(:)
      integer(int64), allocatable, intent(inout) :: fp_now(:)
      integer, allocatable, intent(inout) :: changed_idx(:)
      integer :: n, i

      if (.not. allocated(files)) then
         if (allocated(fp_prev)) deallocate(fp_prev)
         if (allocated(fp_now))  deallocate(fp_now)
         if (allocated(changed_idx)) deallocate(changed_idx)
         allocate(fp_prev(0), fp_now(0), changed_idx(0))
         return
      end if

      n = size(files)

      if (allocated(fp_prev)) deallocate(fp_prev)
      if (allocated(fp_now))  deallocate(fp_now)
      if (allocated(changed_idx)) deallocate(changed_idx)

      allocate(fp_prev(n), fp_now(n), changed_idx(n))

      do i = 1, n
         fp_prev(i) = file_fingerprint(files(i)%s)
      end do
      fp_now = fp_prev
   end subroutine init_fingerprints