nvml-sys 0.0.6

A low-level FFI wrapper around the Persistent Memory Development Kit, PMDK (formerly NVML) and its libraries, including libpmem, libpmemobj and others. Currently tracks master after version 1.3.1.
Persistent Memory Development Kit

This is examples/libpmemobj/array/README.

This directory contains an example application implemented using libpmemobj.
The array example allows to perform basic operations like allocation,
reallocation and de-allocation on persistent array. User can choose
size of new or reallocated array. There are also 3 types of elements which
are supported: int, PMEMoid and TOID with structure containing int variable.

Persistent pointer can be treated as a pointer to the first element of array.
TOID with user's defined structure can be allocated by using POBJ_ALLOC or
POBJ_ZALLOC macros (similarly when using PMEMoid there are pmemobj_alloc() and
pmemobj_zalloc() functions) with proper number elements multiplied by
user-defined structure's size. Access to array's elements can be executed by
using pmemobj_direct() function or just using proper macro.
For example D_RW(test1)[0] points to first element of test1 array.

To allocate new array using application run the following command:
	$ array <file-name> alloc <array-name> <size> <type>

Where <file-name> is file where pool will be created or opened,
<array-name> is user's defined unique name, <size> is number of elements of
persistent array and <type> is one of listed: int, PMEMoid, TOID.

To reallocate existing array run the following command:
	$ array <file-name> realloc <array-name> <size>

To free existing array run the following command:
	$ array <file-name> free <array-name>

To print array's elements run the following command:
	$ array <file-name> print <array-name>

Example of usage:
	$ array /mnt/pmem/testfile alloc test1 10 TOID
	$ array /mnt/pmem/testfile alloc test2 100 int
	$ array /mnt/pmem/testfile realloc test1 50
	$ array /mnt/pmem/testfile realloc test2 5
	$ array /mnt/pmem/testfile print test1
	$ array /mnt/pmem/testfile free test1
	$ array /mnt/pmem/testfile free test2