1. Aleksey Khudyakov
  2. histogram-fill

Commits

Aleksey Khudyakov  committed c1afebc

Correct comment

  • Participants
  • Parent commits 75b7c70
  • Branches default

Comments (0)

Files changed (1)

File histogram-fill/Data/Histogram/ST.hs

View file
 newMHistogram :: (PrimMonad m, Bin bin, M.MVector v a) => a -> bin -> m (MHistogram (PrimState m) v bin a)
 newMHistogram zero bin = do
   let n = nBins bin
-  -- NOTE: replicate behaves strangely when n is negative it may fail
-  --       immediately or proceed and create invalid vector which
-  --       leads to memory corruption. So we want to check that.
+  -- NOTE: replicate will create vector of zero length requested
+  --       length is negative. Thus if number of bins is negative buffer
+  --       will be shorter than 2. And it's assumed that there's always at
+  --       least 2 bin. Consequently it could lead to memory corruption.
   when (n < 0) $
     error "Data.Histogram.ST.newMHistogram: negative number of bins"
   a  <- M.replicate (n + 2) zero