#!../pmemobjcli -s
# This is a script for pmemobjcli application intended to be used with afl.
# The script performs operations on a list.
# usage: ./list.posc <file>

# allocate root object with specified size
pmemobj_root 1024

# allocate four zeroed objects in root object
# at positions 0, 1, 2 and 3
pmemobj_zalloc r.0 4 8192
pmemobj_zalloc r.1 2 256
pmemobj_zalloc r.2 3 128
pmemobj_zalloc r.3 3 128

# duplicate 0 pattern in root object
# at positions 4
pmemobj_strdup r.4 0 5

# allocate and add elements to both lists
pmemobj_memset_persist r.0 0 0 32
pmemobj_list_insert_new r.4 r.0 NULL 1 64 3
pmemobj_list_insert_new r.5 r.1 NULL 1 64 3

# add existing element to first list
pmemobj_list_insert r.3 r.0 r.4 1

# add existing element as a head of second list
pmemobj_list_insert r.2 r.1 NULL 0

# move all elements from first to second list
pmemobj_list_move r.4 r.0 r.1 r.5 0
pmemobj_list_move r.3 r.0 r.1 r.4 0

# remove elements from first list
pmemobj_list_remove r.2 r.1 0
pmemobj_list_remove r.3 r.1 0

# remove elements from second list
pmemobj_list_remove r.4 r.1 1
pmemobj_list_remove r.5 r.1 1

# free allocated objects
pmemobj_free r.0
pmemobj_free r.1
pmemobj_free r.2
pmemobj_free r.3
