diff --git a/code/chapter5/frequency.erl b/code/chapter5/frequency.erl index 9cea6a6..fc9f49b 100644 --- a/code/chapter5/frequency.erl +++ b/code/chapter5/frequency.erl @@ -67,4 +67,8 @@ allocate({[Freq|Free], Allocated}, Pid) -> deallocate({Free, Allocated}, Freq) -> NewAllocated=lists:keydelete(Freq, 1, Allocated), - {[Freq|Free], NewAllocated}. + case NewAllocated of + Allocated -> {Free, Allocated}; + _ -> {[Freq|Free], NewAllocated} + end. +