本文整理汇总了C++中pn_free函数的典型用法代码示例。如果您正苦于以下问题:C++ pn_free函数的具体用法?C++ pn_free怎么用?C++ pn_free使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pn_free函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: test_list_compare
void test_list_compare(void)
{
pn_list_t *a = pn_list(PN_OBJECT, 0);
pn_list_t *b = pn_list(PN_OBJECT, 0);
assert(pn_equals(a, b));
void *one = pn_class_new(PN_OBJECT, 0);
void *two = pn_class_new(PN_OBJECT, 0);
void *three = pn_class_new(PN_OBJECT, 0);
pn_list_add(a, one);
assert(!pn_equals(a, b));
pn_list_add(b, one);
assert(pn_equals(a, b));
pn_list_add(b, two);
assert(!pn_equals(a, b));
pn_list_add(a, two);
assert(pn_equals(a, b));
pn_list_add(a, three);
assert(!pn_equals(a, b));
pn_list_add(b, three);
assert(pn_equals(a, b));
pn_free(a); pn_free(b);
pn_free(one); pn_free(two); pn_free(three);
}
示例2: test_list_inspect
void test_list_inspect(void)
{
pn_list_t *l = build_list(0, END);
test_inspect(l, "[]");
pn_free(l);
l = build_list(0, pn_string("one"), END);
test_inspect(l, "[\"one\"]");
pn_free(l);
l = build_list(0,
pn_string("one"),
pn_string("two"),
END);
test_inspect(l, "[\"one\", \"two\"]");
pn_free(l);
l = build_list(0,
pn_string("one"),
pn_string("two"),
pn_string("three"),
END);
test_inspect(l, "[\"one\", \"two\", \"three\"]");
pn_free(l);
}
示例3: test_build_map_odd
static void test_build_map_odd(void)
{
pn_map_t *m = build_map(0, 0.75,
pn_string("key"),
pn_string("value"),
pn_string("key2"),
pn_string("value2"),
pn_string("key3"),
END);
assert(pn_map_size(m) == 3);
pn_string_t *key = pn_string(NULL);
pn_string_set(key, "key");
assert(pn_strequals(pn_string_get((pn_string_t *) pn_map_get(m, key)),
"value"));
pn_string_set(key, "key2");
assert(pn_strequals(pn_string_get((pn_string_t *) pn_map_get(m, key)),
"value2"));
pn_string_set(key, "key3");
assert(pn_map_get(m, key) == NULL);
pn_free(m);
pn_free(key);
}
示例4: test_map_links
static void test_map_links(void)
{
const pn_class_t collider_clazz = PN_CLASS(collider);
void *keys[3];
for (int i = 0; i < 3; i++)
keys[i] = pn_class_new(&collider_clazz, 0);
// test deleting a head, middle link, tail
for (int delete_idx=0; delete_idx < 3; delete_idx++) {
pn_map_t *map = pn_map(PN_WEAKREF, PN_WEAKREF, 0, 0.75);
// create a chain of entries that have same head (from identical key hashcode)
for (int i = 0; i < 3; i++) {
pn_map_put(map, keys[i], keys[i]);
}
pn_map_del(map, keys[delete_idx]);
for (int i = 0; i < 3; i++) {
void *value = (i == delete_idx) ? NULL : keys[i];
assert (pn_map_get(map, keys[i]) == value);
}
pn_free(map);
}
for (int i = 0; i < 3; i++)
pn_free(keys[i]);
}
示例5: smb_lookuppathvptovp
vnode_t *
smb_lookuppathvptovp(smb_request_t *sr, char *path, vnode_t *startvp,
vnode_t *rootvp)
{
pathname_t pn;
vnode_t *vp = NULL;
int lookup_flags = FOLLOW;
if (SMB_TREE_IS_CASEINSENSITIVE(sr))
lookup_flags |= FIGNORECASE;
(void) pn_alloc(&pn);
if (pn_set(&pn, path) == 0) {
VN_HOLD(startvp);
if (rootvp != rootdir)
VN_HOLD(rootvp);
/* lookuppnvp should release the holds */
if (lookuppnvp(&pn, NULL, lookup_flags, NULL, &vp,
rootvp, startvp, kcred) != 0) {
pn_free(&pn);
return (NULL);
}
}
pn_free(&pn);
return (vp);
}
示例6: test_compare
static void test_compare(void)
{
static pn_class_t clazz = PN_CLASS(compare);
void *a = pn_class_new(&clazz, 0);
assert(a);
void *b = pn_class_new(&clazz, 0);
assert(b);
assert(pn_compare(a, b));
assert(!pn_equals(a, b));
assert(!pn_compare(a, a));
assert(pn_equals(a, a));
assert(!pn_compare(b, b));
assert(pn_equals(b, b));
assert(pn_compare(a, b) == (intptr_t) ((uintptr_t) b - (uintptr_t) a));
assert(pn_compare(NULL, b));
assert(!pn_equals(NULL, b));
assert(pn_compare(a, NULL));
assert(!pn_equals(a, NULL));
assert(!pn_compare(NULL, NULL));
assert(pn_equals(NULL, NULL));
pn_free(a);
pn_free(b);
}
示例7: complete_connect
static void complete_connect(connect_result_t *result, HRESULT status)
{
iocpdesc_t *iocpd = result->base.iocpd;
if (iocpd->closing) {
pn_free(result);
reap_check(iocpd);
return;
}
if (status) {
iocpdesc_fail(iocpd, status, "Connect failure");
// Posix sets selectable events as follows:
pni_events_update(iocpd, PN_READABLE | PN_EXPIRED);
} else {
release_sys_sendbuf(iocpd->socket);
if (setsockopt(iocpd->socket, SOL_SOCKET, SO_UPDATE_CONNECT_CONTEXT, NULL, 0)) {
iocpdesc_fail(iocpd, WSAGetLastError(), "Internal connect failure (update context)");
} else {
pni_events_update(iocpd, PN_WRITABLE);
start_reading(iocpd);
}
}
pn_free(result);
return;
}
示例8: test_map_inspect
void test_map_inspect(void)
{
// note that when there is more than one entry in a map, the order
// of the entries is dependent on the hashes involved, it will be
// deterministic though
pn_map_t *m = build_map(0, 0.75, END);
test_inspect(m, "{}");
pn_free(m);
m = build_map(0, 0.75,
pn_string("key"), pn_string("value"),
END);
test_inspect(m, "{\"key\": \"value\"}");
pn_free(m);
m = build_map(0, 0.75,
pn_string("k1"), pn_string("v1"),
pn_string("k2"), pn_string("v2"),
END);
test_inspect(m, "{\"k1\": \"v1\", \"k2\": \"v2\"}");
pn_free(m);
m = build_map(0, 0.75,
pn_string("k1"), pn_string("v1"),
pn_string("k2"), pn_string("v2"),
pn_string("k3"), pn_string("v3"),
END);
test_inspect(m, "{\"k3\": \"v3\", \"k1\": \"v1\", \"k2\": \"v2\"}");
pn_free(m);
}
示例9: resolve_devfs_name
/*
* given an absolute pathname, convert it, if possible, to a devfs
* name. Examples:
* /dev/rsd3a to /[email protected],4000/[email protected]/[email protected],0:a
* /dev/dsk/c0t0d0s0 to /[email protected],4000/[email protected]/[email protected],0:a
* /devices/[email protected],4000/[email protected]/[email protected],0:a to /[email protected],4000/[email protected]/[email protected],0:a
* /[email protected],4000/[email protected]/[email protected],0:a unchanged
*
* This routine deals with symbolic links, physical pathname with and
* without /devices stripped. Returns 0 on success or -1 on failure.
*/
static int
resolve_devfs_name(char *name, char *buffer)
{
int error;
char *fullname = NULL;
struct pathname pn, rpn;
/* if not a /dev or /device name, prepend /devices */
if (strncmp(name, "/dev/", 5) != 0 &&
strncmp(name, "/devices/", 9) != 0) {
fullname = kmem_alloc(MAXPATHLEN, KM_SLEEP);
(void) snprintf(fullname, MAXPATHLEN, "/devices%s", name);
name = fullname;
}
if (pn_get(name, UIO_SYSSPACE, &pn) != 0) {
if (fullname)
kmem_free(fullname, MAXPATHLEN);
return (-1);
}
pn_alloc(&rpn);
error = lookuppn(&pn, &rpn, FOLLOW, NULL, NULL);
if (error == 0)
bcopy(rpn.pn_path, buffer, rpn.pn_pathlen);
pn_free(&pn);
pn_free(&rpn);
if (fullname)
kmem_free(fullname, MAXPATHLEN);
return (error);
}
示例10: pn_selector_finalize
void pn_selector_finalize(void *obj)
{
pn_selector_t *selector = (pn_selector_t *) obj;
pn_free(selector->selectables);
pn_free(selector->iocp_descriptors);
pn_error_free(selector->error);
selector->iocp->selector = NULL;
}
示例11: pn_subscription_finalize
void pn_subscription_finalize(void *obj)
{
pn_subscription_t *sub = (pn_subscription_t *) obj;
pn_free(sub->scheme);
pn_free(sub->host);
pn_free(sub->port);
pn_free(sub->address);
}
示例12: sender_cleanup
void sender_cleanup(pn_handler_t *h)
{
sender_context_t *sc = sender_context(h);
pn_message_free(sc->message);
pn_message_free(sc->reply_message);
pn_url_free(sc->send_url);
pn_free(sc->hostname);
pn_free(sc->container_id);
free(sc->encoded_data);
}
示例13: localpath
/*
* Given a global path (from rootdir), and a vnode that is the current root,
* return the portion of the path that is beneath the current root or NULL on
* failure. The path MUST be a resolved path (no '..' entries or symlinks),
* otherwise this function will fail.
*/
static char *
localpath(char *path, struct vnode *vrootp, cred_t *cr)
{
vnode_t *vp;
vnode_t *cvp;
char component[MAXNAMELEN];
char *ret = NULL;
pathname_t pn;
/*
* We use vn_compare() instead of VN_CMP() in order to detect lofs
* mounts and stacked vnodes.
*/
if (vn_compare(vrootp, rootdir))
return (path);
if (pn_get(path, UIO_SYSSPACE, &pn) != 0)
return (NULL);
vp = rootdir;
VN_HOLD(vp);
if (vn_ismntpt(vp) && traverse(&vp) != 0) {
VN_RELE(vp);
pn_free(&pn);
return (NULL);
}
while (pn_pathleft(&pn)) {
pn_skipslash(&pn);
if (pn_getcomponent(&pn, component) != 0)
break;
if (VOP_LOOKUP(vp, component, &cvp, &pn, 0, rootdir, cr,
NULL, NULL, NULL) != 0)
break;
VN_RELE(vp);
vp = cvp;
if (vn_ismntpt(vp) && traverse(&vp) != 0)
break;
if (vn_compare(vp, vrootp)) {
ret = path + (pn.pn_path - pn.pn_buf);
break;
}
}
VN_RELE(vp);
pn_free(&pn);
return (ret);
}
示例14: pni_iocpdesc_finalize
static void pni_iocpdesc_finalize(void *object)
{
iocpdesc_t *iocpd = (iocpdesc_t *) object;
pn_free(iocpd->acceptor);
pn_error_free(iocpd->error);
if (iocpd->pipeline)
if (write_in_progress(iocpd))
iocp_log("iocp descriptor write leak\n");
else
pn_free(iocpd->pipeline);
if (iocpd->read_in_progress)
iocp_log("iocp descriptor read leak\n");
else
free(iocpd->read_result);
}
示例15: pn_io_finalize
void pn_io_finalize(void *obj)
{
pn_io_t *io = (pn_io_t *) obj;
pn_error_free(io->error);
pn_free(io->iocp);
WSACleanup();
}