On Thu, Dec 17, 2015 at 9:01 PM, Ted Unangst <t...@tedunangst.com> wrote: > Maxim Pugachev wrote: >> On Sun, Dec 13, 2015 at 10:38 PM, Ted Unangst <t...@tedunangst.com> wrote: >> > Maxim Pugachev wrote: >> >> Currently two checks in free() function confirm the correctness of >> >> freedsize argument. I think that it's better to check that provided >> >> freedsize fall into the same bucket that was recorded in kmemusage >> >> struct: it covers both cases. >> > >> > I don't know. This doesn't seem clearer to me. An error message with >> > bucket numbers isn't any more helpful. >> >> Ted, thank you for your comments! >> >> I can compare the buckets to generate a clearer message, but you're >> right, it'll look a bit complicated. >> >> I've read this code again and I think there is an error in a second >> check ("size too small"). For example, if freedsize = 2048 and size = >> 4096, then panic will not fire because "freedsize < size / 2" is >> false. But I guess it should, because BUCKETINDX(2048) == 11, but >> BUCKETINDX(4096) == 12. >> >> What do you think? > > I remember thinking about this before. I forgot what I thought though. > > Is there some case where the correct size is 1/2? I can't think of any.
I'm sorry, but I think I don't understand your question.