Library topsy_hmFree
Load seplog_header.
Require Import topsy_hm.
Require Import Bool.
Definition hmFree (address: loc) (entry addressEntry tmp result: var.v) :=
entry <- var_e hmStart;
addressEntry <- (nat_e address -e int_e 2%Z);
while ((var_e entry =/= null) &&& (var_e entry =/= var_e addressEntry)) (
tmp <-* (entry -.> next);
entry <- var_e tmp
);
ifte (var_e entry =/= null) thendo (
tmp <-* (entry -.> next);
ifte (var_e tmp =/= null) thendo (
(entry -.> status) *<- Free;
result <- HM_FREEOK)
elsedo
(result <- HM_FREEFAILED)
) elsedo (
result <- HM_FREEFAILED
).
Definition hmFree_specif := forall p x sizex y sizey statusy, p > 0 ->
{{ fun s h => exists l, (Heap_List l p ** Array (x+2) sizex) s h /\
In_hl l (x,sizex, alloc) p /\ In_hl l (y,sizey, statusy) p /\
x <> y /\
s |b= var_e hmStart == nat_e p }}
hmFree (x+2) entry cptr nptr result
{{ fun s h => exists l, Heap_List l p s h /\
In_hl l (x,sizex,free) p /\ In_hl l (y,sizey,statusy) p /\
s |b= var_e result == HM_FREEOK }}.
Lemma hmFree_verif : hmFree_specif.