本文整理汇总了C++中QDECREF函数的典型用法代码示例。如果您正苦于以下问题:C++ QDECREF函数的具体用法?C++ QDECREF怎么用?C++ QDECREF使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了QDECREF函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: openfile
static int openfile(char *name, int flags, bool writethrough, bool force_share,
QDict *opts)
{
Error *local_err = NULL;
if (qemuio_blk) {
error_report("file open already, try 'help close'");
QDECREF(opts);
return 1;
}
if (force_share) {
if (!opts) {
opts = qdict_new();
}
if (qdict_haskey(opts, BDRV_OPT_FORCE_SHARE)
&& !qdict_get_bool(opts, BDRV_OPT_FORCE_SHARE)) {
error_report("-U conflicts with image options");
QDECREF(opts);
return 1;
}
qdict_put_bool(opts, BDRV_OPT_FORCE_SHARE, true);
}
qemuio_blk = blk_new_open(name, NULL, opts, flags, &local_err);
if (!qemuio_blk) {
error_reportf_err(local_err, "can't open%s%s: ",
name ? " device " : "", name ?: "");
return 1;
}
开发者ID:E8-Storage,项目名称:qemu,代码行数:29,代码来源:qemu-io.c
示例2: test_usb_storage_hotplug
static void test_usb_storage_hotplug(void)
{
QDict *response;
response = qmp("{'execute': 'device_add',"
" 'arguments': {"
" 'driver': 'usb-storage',"
" 'drive': 'drive0',"
" 'id': 'usbdev0'"
"}}");
g_assert(response);
g_assert(!qdict_haskey(response, "error"));
QDECREF(response);
response = qmp("{'execute': 'device_del',"
" 'arguments': {"
" 'id': 'usbdev0'"
"}}");
g_assert(response);
g_assert(!qdict_haskey(response, "error"));
QDECREF(response);
response = qmp("");
g_assert(response);
g_assert(qdict_haskey(response, "event"));
g_assert(!strcmp(qdict_get_str(response, "event"), "DEVICE_DELETED"));
QDECREF(response);
}
开发者ID:JunaidLoonat,项目名称:qemu,代码行数:28,代码来源:usb-hcd-uhci-test.c
示例3: qnull_visit_test
static void qnull_visit_test(void)
{
QObject *obj;
Visitor *v;
QNull *null;
/*
* Most tests of interactions between QObject and visitors are in
* test-qmp-*-visitor; but these tests live here because they
* depend on layering violations to check qnull_ refcnt.
*/
g_assert(qnull_.base.refcnt == 1);
obj = QOBJECT(qnull());
v = qobject_input_visitor_new(obj);
qobject_decref(obj);
visit_type_null(v, NULL, &null, &error_abort);
g_assert(obj == QOBJECT(&qnull_));
QDECREF(null);
visit_free(v);
null = NULL;
v = qobject_output_visitor_new(&obj);
visit_type_null(v, NULL, &null, &error_abort);
visit_complete(v, &obj);
g_assert(obj == QOBJECT(&qnull_));
QDECREF(null);
qobject_decref(obj);
visit_free(v);
g_assert(qnull_.base.refcnt == 1);
}
开发者ID:8tab,项目名称:qemu,代码行数:32,代码来源:check-qnull.c
示例4: qdict_crumple_test_bad_inputs
static void qdict_crumple_test_bad_inputs(void)
{
QDict *src;
Error *error = NULL;
src = qdict_new();
/* rule.0 can't be both a string and a dict */
qdict_put(src, "rule.0", qstring_from_str("fred"));
qdict_put(src, "rule.0.policy", qstring_from_str("allow"));
g_assert(qdict_crumple(src, &error) == NULL);
g_assert(error != NULL);
error_free(error);
error = NULL;
QDECREF(src);
src = qdict_new();
/* rule can't be both a list and a dict */
qdict_put(src, "rule.0", qstring_from_str("fred"));
qdict_put(src, "rule.a", qstring_from_str("allow"));
g_assert(qdict_crumple(src, &error) == NULL);
g_assert(error != NULL);
error_free(error);
error = NULL;
QDECREF(src);
src = qdict_new();
/* The input should be flat, ie no dicts or lists */
qdict_put(src, "rule.a", qdict_new());
qdict_put(src, "rule.b", qstring_from_str("allow"));
g_assert(qdict_crumple(src, &error) == NULL);
g_assert(error != NULL);
error_free(error);
error = NULL;
QDECREF(src);
src = qdict_new();
/* List indexes must not have gaps */
qdict_put(src, "rule.0", qstring_from_str("deny"));
qdict_put(src, "rule.3", qstring_from_str("allow"));
g_assert(qdict_crumple(src, &error) == NULL);
g_assert(error != NULL);
error_free(error);
error = NULL;
QDECREF(src);
src = qdict_new();
/* List indexes must be in %zu format */
qdict_put(src, "rule.0", qstring_from_str("deny"));
qdict_put(src, "rule.+1", qstring_from_str("allow"));
g_assert(qdict_crumple(src, &error) == NULL);
g_assert(error != NULL);
error_free(error);
error = NULL;
QDECREF(src);
}
开发者ID:AmesianX,项目名称:panda,代码行数:60,代码来源:check-qdict.c
示例5: test_dispatch_cmd_failure
/* test commands that return an error due to invalid parameters */
static void test_dispatch_cmd_failure(void)
{
QDict *req = qdict_new();
QDict *args = qdict_new();
QObject *resp;
qdict_put_obj(req, "execute", QOBJECT(qstring_from_str("user_def_cmd2")));
resp = qmp_dispatch(&qmp_commands, QOBJECT(req));
assert(resp != NULL);
assert(qdict_haskey(qobject_to_qdict(resp), "error"));
qobject_decref(resp);
QDECREF(req);
/* check that with extra arguments it throws an error */
req = qdict_new();
qdict_put(args, "a", qint_from_int(66));
qdict_put(req, "arguments", args);
qdict_put_obj(req, "execute", QOBJECT(qstring_from_str("user_def_cmd")));
resp = qmp_dispatch(&qmp_commands, QOBJECT(req));
assert(resp != NULL);
assert(qdict_haskey(qobject_to_qdict(resp), "error"));
qobject_decref(resp);
QDECREF(req);
}
开发者ID:JunaidLoonat,项目名称:qemu,代码行数:30,代码来源:test-qmp-commands.c
示例6: hotplug
static void hotplug(void)
{
QDict *response;
QOSState *qs;
qs = qvirtio_scsi_start(
"-drive id=drv1,if=none,file=null-co://,format=raw");
response = qmp("{\"execute\": \"device_add\","
" \"arguments\": {"
" \"driver\": \"scsi-hd\","
" \"id\": \"scsi-hd\","
" \"drive\": \"drv1\""
"}}");
g_assert(response);
g_assert(!qdict_haskey(response, "error"));
QDECREF(response);
response = qmp("{\"execute\": \"device_del\","
" \"arguments\": {"
" \"id\": \"scsi-hd\""
"}}");
g_assert(response);
g_assert(!qdict_haskey(response, "error"));
g_assert(qdict_haskey(response, "event"));
g_assert(!strcmp(qdict_get_str(response, "event"), "DEVICE_DELETED"));
QDECREF(response);
qvirtio_scsi_stop(qs);
}
开发者ID:mdroth,项目名称:qemu,代码行数:30,代码来源:virtio-scsi-test.c
示例7: send_response
static int send_response(GAState *s, QObject *payload)
{
const char *buf;
QString *payload_qstr, *response_qstr;
GIOStatus status;
g_assert(payload && s->channel);
payload_qstr = qobject_to_json(payload);
if (!payload_qstr) {
return -EINVAL;
}
if (s->delimit_response) {
s->delimit_response = false;
response_qstr = qstring_new();
qstring_append_chr(response_qstr, QGA_SENTINEL_BYTE);
qstring_append(response_qstr, qstring_get_str(payload_qstr));
QDECREF(payload_qstr);
} else {
response_qstr = payload_qstr;
}
qstring_append_chr(response_qstr, '\n');
buf = qstring_get_str(response_qstr);
status = ga_channel_write_all(s->channel, buf, strlen(buf));
QDECREF(response_qstr);
if (status != G_IO_STATUS_NORMAL) {
return -EIO;
}
return 0;
}
开发者ID:JunaidLoonat,项目名称:qemu,代码行数:33,代码来源:main.c
示例8: test_drive_add_empty
static void test_drive_add_empty(void)
{
QDict *response;
const char *response_return;
/* Start with an empty drive */
qtest_start("-drive if=none,id=drive0");
/* Delete the drive */
response = qmp("{\"execute\": \"human-monitor-command\","
" \"arguments\": {"
" \"command-line\": \"drive_del drive0\""
"}}");
g_assert(response);
response_return = qdict_get_try_str(response, "return");
g_assert(response_return);
g_assert(strcmp(response_return, "") == 0);
QDECREF(response);
/* Ensure re-adding the drive works - there should be no duplicate ID error
* because the old drive must be gone.
*/
response = qmp("{\"execute\": \"human-monitor-command\","
" \"arguments\": {"
" \"command-line\": \"drive_add 0 if=none,id=drive0\""
"}}");
g_assert(response);
response_return = qdict_get_try_str(response, "return");
g_assert(response_return);
g_assert(strcmp(response_return, "OK\r\n") == 0);
QDECREF(response);
qtest_end();
}
开发者ID:AbnerChang,项目名称:RiscVQemuPcat,代码行数:34,代码来源:blockdev-test.c
示例9: qdict_crumple_test_recursive
static void qdict_crumple_test_recursive(void)
{
QDict *src, *dst, *rule, *vnc, *acl, *listen;
QList *rules;
src = qdict_new();
qdict_put(src, "vnc.listen.addr", qstring_from_str("127.0.0.1"));
qdict_put(src, "vnc.listen.port", qstring_from_str("5901"));
qdict_put(src, "vnc.acl.rules.0.match", qstring_from_str("fred"));
qdict_put(src, "vnc.acl.rules.0.policy", qstring_from_str("allow"));
qdict_put(src, "vnc.acl.rules.1.match", qstring_from_str("bob"));
qdict_put(src, "vnc.acl.rules.1.policy", qstring_from_str("deny"));
qdict_put(src, "vnc.acl.default", qstring_from_str("deny"));
qdict_put(src, "vnc.acl..name", qstring_from_str("acl0"));
qdict_put(src, "vnc.acl.rule..name", qstring_from_str("acl0"));
dst = qobject_to_qdict(qdict_crumple(src, &error_abort));
g_assert(dst);
g_assert_cmpint(qdict_size(dst), ==, 1);
vnc = qdict_get_qdict(dst, "vnc");
g_assert(vnc);
g_assert_cmpint(qdict_size(vnc), ==, 3);
listen = qdict_get_qdict(vnc, "listen");
g_assert(listen);
g_assert_cmpint(qdict_size(listen), ==, 2);
g_assert_cmpstr("127.0.0.1", ==, qdict_get_str(listen, "addr"));
g_assert_cmpstr("5901", ==, qdict_get_str(listen, "port"));
acl = qdict_get_qdict(vnc, "acl");
g_assert(acl);
g_assert_cmpint(qdict_size(acl), ==, 3);
rules = qdict_get_qlist(acl, "rules");
g_assert(rules);
g_assert_cmpint(qlist_size(rules), ==, 2);
rule = qobject_to_qdict(qlist_pop(rules));
g_assert(rule);
g_assert_cmpint(qdict_size(rule), ==, 2);
g_assert_cmpstr("fred", ==, qdict_get_str(rule, "match"));
g_assert_cmpstr("allow", ==, qdict_get_str(rule, "policy"));
QDECREF(rule);
rule = qobject_to_qdict(qlist_pop(rules));
g_assert(rule);
g_assert_cmpint(qdict_size(rule), ==, 2);
g_assert_cmpstr("bob", ==, qdict_get_str(rule, "match"));
g_assert_cmpstr("deny", ==, qdict_get_str(rule, "policy"));
QDECREF(rule);
/* With recursive crumpling, we should see all names unescaped */
g_assert_cmpstr("acl0", ==, qdict_get_str(vnc, "acl.name"));
g_assert_cmpstr("acl0", ==, qdict_get_str(acl, "rule.name"));
QDECREF(src);
QDECREF(dst);
}
开发者ID:JunaidLoonat,项目名称:qemu,代码行数:59,代码来源:check-qdict.c
示例10: qdict_crumple_test_empty
static void qdict_crumple_test_empty(void)
{
QDict *src, *dst;
src = qdict_new();
dst = (QDict *)qdict_crumple(src, &error_abort);
g_assert_cmpint(qdict_size(dst), ==, 0);
QDECREF(src);
QDECREF(dst);
}
开发者ID:AmesianX,项目名称:panda,代码行数:13,代码来源:check-qdict.c
示例11: test_dispatch_cmd_io
/* test commands that involve both input parameters and return values */
static void test_dispatch_cmd_io(void)
{
QDict *req = qdict_new();
QDict *args = qdict_new();
QDict *args3 = qdict_new();
QDict *ud1a = qdict_new();
QDict *ud1b = qdict_new();
QDict *ret, *ret_dict, *ret_dict_dict, *ret_dict_dict_userdef;
QDict *ret_dict_dict2, *ret_dict_dict2_userdef;
QNum *ret3;
int64_t val;
qdict_put_int(ud1a, "integer", 42);
qdict_put_str(ud1a, "string", "hello");
qdict_put_int(ud1b, "integer", 422);
qdict_put_str(ud1b, "string", "hello2");
qdict_put(args, "ud1a", ud1a);
qdict_put(args, "ud1b", ud1b);
qdict_put(req, "arguments", args);
qdict_put_str(req, "execute", "user_def_cmd2");
ret = qobject_to_qdict(test_qmp_dispatch(req));
assert(!strcmp(qdict_get_str(ret, "string0"), "blah1"));
ret_dict = qdict_get_qdict(ret, "dict1");
assert(!strcmp(qdict_get_str(ret_dict, "string1"), "blah2"));
ret_dict_dict = qdict_get_qdict(ret_dict, "dict2");
ret_dict_dict_userdef = qdict_get_qdict(ret_dict_dict, "userdef");
assert(qdict_get_int(ret_dict_dict_userdef, "integer") == 42);
assert(!strcmp(qdict_get_str(ret_dict_dict_userdef, "string"), "hello"));
assert(!strcmp(qdict_get_str(ret_dict_dict, "string"), "blah3"));
ret_dict_dict2 = qdict_get_qdict(ret_dict, "dict3");
ret_dict_dict2_userdef = qdict_get_qdict(ret_dict_dict2, "userdef");
assert(qdict_get_int(ret_dict_dict2_userdef, "integer") == 422);
assert(!strcmp(qdict_get_str(ret_dict_dict2_userdef, "string"), "hello2"));
assert(!strcmp(qdict_get_str(ret_dict_dict2, "string"), "blah4"));
QDECREF(ret);
qdict_put_int(args3, "a", 66);
qdict_put(req, "arguments", args3);
qdict_put_str(req, "execute", "guest-get-time");
ret3 = qobject_to_qnum(test_qmp_dispatch(req));
g_assert(qnum_get_try_int(ret3, &val));
g_assert_cmpint(val, ==, 66);
QDECREF(ret3);
QDECREF(req);
}
开发者ID:8tab,项目名称:qemu,代码行数:50,代码来源:test-qmp-commands.c
示例12: process_event
/* handle requests/control events coming in over the channel */
static void process_event(JSONMessageParser *parser, QList *tokens)
{
GAState *s = container_of(parser, GAState, parser);
QObject *obj;
QDict *qdict;
Error *err = NULL;
int ret;
g_assert(s && parser);
g_debug("process_event: called");
obj = json_parser_parse_err(tokens, NULL, &err);
if (err || !obj || qobject_type(obj) != QTYPE_QDICT) {
qobject_decref(obj);
qdict = qdict_new();
if (!err) {
g_warning("failed to parse event: unknown error");
error_set(&err, QERR_JSON_PARSING);
} else {
g_warning("failed to parse event: %s", error_get_pretty(err));
}
qdict_put_obj(qdict, "error", error_get_qobject(err));
error_free(err);
} else {
qdict = qobject_to_qdict(obj);
}
g_assert(qdict);
/* handle host->guest commands */
if (qdict_haskey(qdict, "execute")) {
process_command(s, qdict);
} else {
if (!qdict_haskey(qdict, "error")) {
QDECREF(qdict);
qdict = qdict_new();
g_warning("unrecognized payload format");
error_set(&err, QERR_UNSUPPORTED);
qdict_put_obj(qdict, "error", error_get_qobject(err));
error_free(err);
}
ret = conn_channel_send_payload(s->conn_channel, QOBJECT(qdict));
if (ret) {
g_warning("error sending payload: %s", strerror(ret));
}
}
QDECREF(qdict);
}
开发者ID:AsherBond,项目名称:qemu-kvm,代码行数:50,代码来源:qemu-ga.c
示例13: test_dispatch_cmd_io
/* test commands that involve both input parameters and return values */
static void test_dispatch_cmd_io(void)
{
QDict *req = qdict_new();
QDict *args = qdict_new();
QDict *ud1a = qdict_new();
QDict *ud1b = qdict_new();
QObject *resp;
qdict_put_obj(ud1a, "integer", QOBJECT(qint_from_int(42)));
qdict_put_obj(ud1a, "string", QOBJECT(qstring_from_str("hello")));
qdict_put_obj(ud1b, "integer", QOBJECT(qint_from_int(422)));
qdict_put_obj(ud1b, "string", QOBJECT(qstring_from_str("hello2")));
qdict_put_obj(args, "ud1a", QOBJECT(ud1a));
qdict_put_obj(args, "ud1b", QOBJECT(ud1b));
qdict_put_obj(req, "arguments", QOBJECT(args));
qdict_put_obj(req, "execute", QOBJECT(qstring_from_str("user_def_cmd2")));
/* TODO: put in full payload and check for errors */
resp = qmp_dispatch(QOBJECT(req));
assert(resp != NULL);
assert(!qdict_haskey(qobject_to_qdict(resp), "error"));
g_print("\nresp: %s\n", qstring_get_str(qobject_to_json_pretty(resp)));
qobject_decref(resp);
QDECREF(req);
}
开发者ID:B-Rich,项目名称:serialice,代码行数:28,代码来源:test-qmp-commands.c
示例14: qobject_to_qdict_test
static void qobject_to_qdict_test(void)
{
QDict *tests_dict = qdict_new();
g_assert(qobject_to_qdict(QOBJECT(tests_dict)) == tests_dict);
QDECREF(tests_dict);
}
开发者ID:AmesianX,项目名称:panda,代码行数:7,代码来源:check-qdict.c
示例15: test_dealloc_partial
/* test generated deallocation on an object whose construction was prematurely
* terminated due to an error */
static void test_dealloc_partial(void)
{
static const char text[] = "don't leak me";
UserDefTwo *ud2 = NULL;
Error *err = NULL;
/* create partial object */
{
QDict *ud2_dict;
QmpInputVisitor *qiv;
ud2_dict = qdict_new();
qdict_put_obj(ud2_dict, "string0", QOBJECT(qstring_from_str(text)));
qiv = qmp_input_visitor_new(QOBJECT(ud2_dict));
visit_type_UserDefTwo(qmp_input_get_visitor(qiv), &ud2, NULL, &err);
qmp_input_visitor_cleanup(qiv);
QDECREF(ud2_dict);
}
/* verify partial success */
assert(ud2 != NULL);
assert(ud2->string0 != NULL);
assert(strcmp(ud2->string0, text) == 0);
assert(ud2->dict1 == NULL);
/* confirm & release construction error */
assert(err != NULL);
error_free(err);
/* tear down partial object */
qapi_free_UserDefTwo(ud2);
}
开发者ID:kevinzhang1986,项目名称:qemu,代码行数:36,代码来源:test-qmp-commands.c
示例16: qdict_haskey_not_test
static void qdict_haskey_not_test(void)
{
QDict *tests_dict = qdict_new();
g_assert(qdict_haskey(tests_dict, "test") == 0);
QDECREF(tests_dict);
}
开发者ID:AmesianX,项目名称:panda,代码行数:7,代码来源:check-qdict.c
示例17: usb_test_hotplug
void usb_test_hotplug(const char *hcd_id, const int port,
void (*port_check)(void))
{
QDict *response;
char *cmd;
cmd = g_strdup_printf("{'execute': 'device_add',"
" 'arguments': {"
" 'driver': 'usb-tablet',"
" 'port': '%d',"
" 'bus': '%s.0',"
" 'id': 'usbdev%d'"
"}}", port, hcd_id, port);
response = qmp(cmd);
g_free(cmd);
g_assert(response);
g_assert(!qdict_haskey(response, "error"));
QDECREF(response);
if (port_check) {
port_check();
}
cmd = g_strdup_printf("{'execute': 'device_del',"
" 'arguments': {"
" 'id': 'usbdev%d'"
"}}", port);
response = qmp(cmd);
g_free(cmd);
g_assert(response);
g_assert(qdict_haskey(response, "event"));
g_assert(!strcmp(qdict_get_str(response, "event"), "DEVICE_DELETED"));
}
开发者ID:32bitmicro,项目名称:riscv-qemu,代码行数:33,代码来源:usb.c
示例18: qdict_get_not_exists_test
static void qdict_get_not_exists_test(void)
{
QDict *tests_dict = qdict_new();
g_assert(qdict_get(tests_dict, "foo") == NULL);
QDECREF(tests_dict);
}
开发者ID:AmesianX,项目名称:panda,代码行数:7,代码来源:check-qdict.c
示例19: conn_channel_send_payload
static int conn_channel_send_payload(GIOChannel *channel, QObject *payload)
{
int ret = 0;
const char *buf;
QString *payload_qstr;
GError *err = NULL;
g_assert(payload && channel);
payload_qstr = qobject_to_json(payload);
if (!payload_qstr) {
return -EINVAL;
}
qstring_append_chr(payload_qstr, '\n');
buf = qstring_get_str(payload_qstr);
ret = conn_channel_send_buf(channel, buf, strlen(buf));
if (ret) {
goto out_free;
}
g_io_channel_flush(channel, &err);
if (err != NULL) {
g_warning("error flushing payload: %s", err->message);
ret = err->code;
goto out_free;
}
out_free:
QDECREF(payload_qstr);
if (err) {
g_error_free(err);
}
return ret;
}
开发者ID:AsherBond,项目名称:qemu-kvm,代码行数:35,代码来源:qemu-ga.c
示例20: qdict_iterapi_test
static void qdict_iterapi_test(void)
{
int count;
const QDictEntry *ent;
QDict *tests_dict = qdict_new();
g_assert(qdict_first(tests_dict) == NULL);
qdict_put(tests_dict, "key1", qint_from_int(1));
qdict_put(tests_dict, "key2", qint_from_int(2));
qdict_put(tests_dict, "key3", qint_from_int(3));
count = 0;
for (ent = qdict_first(tests_dict); ent; ent = qdict_next(tests_dict, ent)){
g_assert(qdict_haskey(tests_dict, qdict_entry_key(ent)) == 1);
count++;
}
g_assert(count == qdict_size(tests_dict));
/* Do it again to test restarting */
count = 0;
for (ent = qdict_first(tests_dict); ent; ent = qdict_next(tests_dict, ent)){
g_assert(qdict_haskey(tests_dict, qdict_entry_key(ent)) == 1);
count++;
}
g_assert(count == qdict_size(tests_dict));
QDECREF(tests_dict);
}
开发者ID:AmesianX,项目名称:panda,代码行数:31,代码来源:check-qdict.c
注:本文中的QDECREF函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论