88
Using a valid pop pointer, you can use the pmemobj_root() function to get a pointer
of the root object. Internally, this function creates a valid pointer by adding the current
memory address of the mapped pool plus the internal offset to the root.
Opening and Reading from Memory Pools
You create a pool using pmemobj_create(), and you open an existing pool using
pmemobj_open(). Both functions return a PMEMobjpool *pop pointer. The pwriter
example in Listing 7-1 shows how to create a pool and write a string to it. Listing 7-2
shows how to open the same pool to read and display the string.
Listing 7-2. preader.c – An example showing how to open a pool and access the
root object and data
33 /*
34 * preader.c - Read a string from a
35 *
persistent memory pool
36 */
37
38 #include
39 #include
40 #include
41
Figure 7-1. A high-level overview of a persistent memory pool with a pool object
pointer (POP) pointing to the root object
Chapter 7 libpmemobj: a Native traNsaCtioNal objeCt store
Précédent

- 115/457

Suivant