Implement the *allocx() API.
Implement the *allocx() API, which is a successor to the *allocm() API. The *allocx() functions are slightly simpler to use because they have fewer parameters, they directly return the results of primary interest, and mallocx()/rallocx() avoid the strict aliasing pitfall that allocm()/rallocx() share with posix_memalign(). The following code violates strict aliasing rules: foo_t *foo; allocm((void **)&foo, NULL, 42, 0); whereas the following is safe: foo_t *foo; void *p; allocm(&p, NULL, 42, 0); foo = (foo_t *)p; mallocx() does not have this problem: foo_t *foo = (foo_t *)mallocx(42, 0);
This commit is contained in:
@@ -39,8 +39,7 @@ thd_receiver_start(void *arg)
|
||||
for (i = 0; i < (NSENDERS * NMSGS); i++) {
|
||||
mq_msg_t *msg = mq_get(mq);
|
||||
assert_ptr_not_null(msg, "mq_get() should never return NULL");
|
||||
assert_d_eq(jet_dallocm(msg, 0), ALLOCM_SUCCESS,
|
||||
"Unexpected dallocm() failure");
|
||||
jet_dallocx(msg, 0);
|
||||
}
|
||||
return (NULL);
|
||||
}
|
||||
@@ -54,8 +53,8 @@ thd_sender_start(void *arg)
|
||||
for (i = 0; i < NMSGS; i++) {
|
||||
mq_msg_t *msg;
|
||||
void *p;
|
||||
assert_d_eq(jet_allocm(&p, NULL, sizeof(mq_msg_t), 0),
|
||||
ALLOCM_SUCCESS, "Unexpected allocm() failure");
|
||||
p = jet_mallocx(sizeof(mq_msg_t), 0);
|
||||
assert_ptr_not_null(p, "Unexpected allocm() failure");
|
||||
msg = (mq_msg_t *)p;
|
||||
mq_put(mq, msg);
|
||||
}
|
||||
|
Reference in New Issue
Block a user