99
66
PMEMoid str = pmemobj_reserve(pool, act + 0,
67
len, 0);
68
if (OID_IS_NULL(str))
69
die("Can't allocate string: %m\n");
..
75
pmemobj_memcpy(pool, pmemobj_direct(str), name,
76
len, PMEMOBJ_F_MEM_NODRAIN);
77
TOID(struct account) acc;
78
PMEMoid acc_oid = pmemobj_reserve(pool, act + 1,
79
sizeof(struct account), 1);
80
TOID_ASSIGN(acc, acc_oid);
81
if (TOID_IS_NULL(acc))
82
die("Can't allocate account: %m\n");
83
D_RW(acc)->name = str;
84
D_RW(acc)->balance = deposit;
85
pmemobj_persist(pool, D_RW(acc),
86
sizeof(struct account));
87
pmemobj_publish(pool, act, 2);
88
return acc_oid;
89 }
90
91 int main()
92 {
93
if (!(pool = pmemobj_create(POOL, " ",
94
PMEMOBJ_MIN_POOL, 0600)))
95
die("Can't create pool "%s": %m\n", POOL);
96
97
TOID(struct account) account_a, account_b;
98
TOID_ASSIGN(account_a,
99
new_account("Julius Caesar", 100));
100
TOID_ASSIGN(account_b,
101
new_account("Mark Anthony", 50));
102
103
int price = 42;
104
struct pobj_action act[2];
Chapter 7 libpmemobj: a Native traNsaCtioNal objeCt store
66
PMEMoid str = pmemobj_reserve(pool, act + 0,
67
len, 0);
68
if (OID_IS_NULL(str))
69
die("Can't allocate string: %m\n");
..
75
pmemobj_memcpy(pool, pmemobj_direct(str), name,
76
len, PMEMOBJ_F_MEM_NODRAIN);
77
TOID(struct account) acc;
78
PMEMoid acc_oid = pmemobj_reserve(pool, act + 1,
79
sizeof(struct account), 1);
80
TOID_ASSIGN(acc, acc_oid);
81
if (TOID_IS_NULL(acc))
82
die("Can't allocate account: %m\n");
83
D_RW(acc)->name = str;
84
D_RW(acc)->balance = deposit;
85
pmemobj_persist(pool, D_RW(acc),
86
sizeof(struct account));
87
pmemobj_publish(pool, act, 2);
88
return acc_oid;
89 }
90
91 int main()
92 {
93
if (!(pool = pmemobj_create(POOL, " ",
94
PMEMOBJ_MIN_POOL, 0600)))
95
die("Can't create pool "%s": %m\n", POOL);
96
97
TOID(struct account) account_a, account_b;
98
TOID_ASSIGN(account_a,
99
new_account("Julius Caesar", 100));
100
TOID_ASSIGN(account_b,
101
new_account("Mark Anthony", 50));
102
103
int price = 42;
104
struct pobj_action act[2];
Chapter 7 libpmemobj: a Native traNsaCtioNal objeCt store
