本文整理汇总了C++中x_return_val_if_fail函数的典型用法代码示例。如果您正苦于以下问题:C++ x_return_val_if_fail函数的具体用法?C++ x_return_val_if_fail怎么用?C++ x_return_val_if_fail使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了x_return_val_if_fail函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: xmmsc_ipc_io_in_callback
int
xmmsc_ipc_io_in_callback (xmmsc_ipc_t *ipc)
{
bool disco = false;
x_return_val_if_fail (ipc, false);
x_return_val_if_fail (!ipc->disconnect, false);
while (!disco) {
if (!ipc->read_msg)
ipc->read_msg = xmms_ipc_msg_alloc ();
if (xmms_ipc_msg_read_transport (ipc->read_msg, ipc->transport, &disco)) {
xmms_ipc_msg_t *msg = ipc->read_msg;
/* must unset read_msg here,
because exec_msg can cause reentrancy */
ipc->read_msg = NULL;
xmmsc_ipc_exec_msg (ipc, msg);
} else {
break;
}
}
if (disco)
xmmsc_ipc_disconnect (ipc);
return !disco;
}
示例2: x_bytes_unref_to_data
xPointer x_bytes_unref_to_data(xBytes *bytes, xSize *size)
{
xPointer result;
x_return_val_if_fail(bytes != NULL, NULL);
x_return_val_if_fail(size != NULL, NULL);
/*
* Optimal path: if this is was the last reference, then we can return
* the data from this xBytes without copying.
*/
result = try_steal_and_unref(bytes, free, size);
if (result == NULL)
{
/*
* Copy: Non malloc (or compatible) allocater, or static memory,
* so we have to copy, and then unref.
*/
result = memdup(bytes->data, bytes->size);
*size = bytes->size;
x_bytes_unref(bytes);
}
return result;
}
示例3: xmmsc_ipc_io_out_callback
int
xmmsc_ipc_io_out_callback (xmmsc_ipc_t *ipc)
{
bool disco = false;
x_return_val_if_fail (ipc, false);
x_return_val_if_fail (!ipc->disconnect, false);
while (!x_queue_is_empty (ipc->out_msg)) {
xmms_ipc_msg_t *msg = x_queue_peek_head (ipc->out_msg);
if (xmms_ipc_msg_write_transport (msg, ipc->transport, &disco)) {
x_queue_pop_head (ipc->out_msg);
xmms_ipc_msg_destroy (msg);
} else {
break;
}
}
if (disco) {
xmmsc_ipc_disconnect (ipc);
} else {
if (ipc->need_out_callback)
ipc->need_out_callback (xmmsc_ipc_io_out (ipc),
ipc->need_out_data);
}
return !disco;
}
示例4: x_bytes_new_from_bytes
xBytes* x_bytes_new_from_bytes(xBytes *bytes, xSize offset, xSize length)
{
/* Note that length may be 0. */
x_return_val_if_fail(bytes != NULL, NULL);
x_return_val_if_fail(offset <= bytes->size, NULL);
x_return_val_if_fail(offset + length <= bytes->size, NULL);
return x_bytes_new_with_free_func((xChar*)bytes->data + offset, length, x_bytes_unref, x_bytes_ref(bytes));
}
示例5: x_bytes_equal
xBoolean x_bytes_equal(xConstPointer bytes1, xConstPointer bytes2)
{
const xBytes *b1 = bytes1;
const xBytes *b2 = bytes2;
x_return_val_if_fail(bytes1 != NULL, FALSE);
x_return_val_if_fail(bytes2 != NULL, FALSE);
return b1->size == b2->size && memcmp(b1->data, b2->data, b1->size) == 0;
}
示例6: x_serialport_read
xInt32 x_serialport_read(xSerialPort *port, xUInt8 *buffer, xInt32 count)
{
x_return_val_if_fail(port, -1);
x_return_val_if_fail(buffer, -1);
x_return_val_if_fail(count > 0, -1);
if (!x_serialport_is_open(port))
return -1;
return x_serialport_platform_read(port->platform, buffer, count);
}
示例7: xmms_ipc_msg_read_transport
/**
* Try to read message from transport into msg.
*
* @returns TRUE if message is fully read.
*/
bool
xmms_ipc_msg_read_transport (xmms_ipc_msg_t *msg,
xmms_ipc_transport_t *transport,
bool *disconnected)
{
char buf[512];
unsigned int ret, len, rlen;
x_return_val_if_fail (msg, false);
x_return_val_if_fail (transport, false);
while (true) {
len = XMMS_IPC_MSG_HEAD_LEN;
if (msg->xfered >= XMMS_IPC_MSG_HEAD_LEN) {
len += xmms_ipc_msg_get_length (msg);
if (msg->xfered == len) {
return true;
}
}
x_return_val_if_fail (msg->xfered < len, false);
rlen = len - msg->xfered;
if (rlen > sizeof (buf))
rlen = sizeof (buf);
ret = xmms_ipc_transport_read (transport, buf, rlen);
if (ret == SOCKET_ERROR) {
if (xmms_socket_error_recoverable ()) {
return false;
}
if (disconnected) {
*disconnected = true;
}
return false;
} else if (ret == 0) {
if (disconnected) {
*disconnected = true;
}
return false;
} else {
xmmsv_bitbuffer_goto (msg->bb, msg->xfered * 8);
xmmsv_bitbuffer_put_data (msg->bb, (unsigned char *) buf, ret);
msg->xfered += ret;
xmmsv_bitbuffer_goto (msg->bb, XMMS_IPC_MSG_HEAD_LEN * 8);
}
}
}
示例8: x_serialport_set_write_buffer_size
xBoolean x_serialport_set_write_buffer_size(xSerialPort *port, xInt32 value)
{
x_return_val_if_fail(port, FALSE);
x_return_val_if_fail(value > 0, FALSE);
if (x_serialport_is_open(port))
return FALSE;
port->write_buffer_size = value;
return TRUE;
}
示例9: x_serialport_set_port_name
xBoolean x_serialport_set_port_name(xSerialPort *port, const xChar *value)
{
x_return_val_if_fail(port, FALSE);
x_return_val_if_fail(value, FALSE);
if (x_serialport_is_open(port))
return FALSE;
port->port_name = x_string_assign(port->port_name, value);
return TRUE;
}
示例10: xmms_ipc_tcp_write
static int
xmms_ipc_tcp_write (xmms_ipc_transport_t *ipct, char *buffer, int len)
{
xmms_socket_t fd;
x_return_val_if_fail (ipct, -1);
x_return_val_if_fail (buffer, -1);
fd = ipct->fd;
return send (fd, buffer, len, 0);
}
示例11: xmmsc_ipc_connect
bool
xmmsc_ipc_connect (xmmsc_ipc_t *ipc, char *path)
{
x_return_val_if_fail (ipc, false);
x_return_val_if_fail (path, false);
ipc->transport = xmms_ipc_client_init (path);
if (!ipc->transport) {
ipc->error = strdup ("Could not init client!");
return false;
}
return true;
}
示例12: xmms_ipc_tcp_read
static int
xmms_ipc_tcp_read (xmms_ipc_transport_t *ipct, char *buffer, int len)
{
xmms_socket_t fd;
int ret;
x_return_val_if_fail (ipct, -1);
x_return_val_if_fail (buffer, -1);
fd = ipct->fd;
ret = recv (fd, buffer, len, 0);
return ret;
}
示例13: x_bytes_compare
xInt x_bytes_compare(xConstPointer bytes1, xConstPointer bytes2)
{
const xBytes *b1 = bytes1;
const xBytes *b2 = bytes2;
xInt ret;
x_return_val_if_fail(bytes1 != NULL, 0);
x_return_val_if_fail(bytes2 != NULL, 0);
ret = memcmp(b1->data, b2->data, MIN(b1->size, b2->size));
if (ret == 0 && b1->size != b2->size)
ret = b1->size < b2->size ? -1 : 1;
return ret;
}
示例14: xmmsv_coll_idlist_remove
/**
* Remove the value at a given index from the idlist.
* @param coll The collection to update.
* @param index The index at which to remove the value.
* @return TRUE on success, false otherwise.
*/
int
xmmsv_coll_idlist_remove (xmmsv_t *coll, int index)
{
x_return_val_if_fail (coll, 0);
return xmmsv_list_remove (coll->value.coll->idlist, index);
}
示例15: xmmsc_ipc_io_out
int
xmmsc_ipc_io_out (xmmsc_ipc_t *ipc)
{
x_return_val_if_fail (ipc, false);
return !x_queue_is_empty (ipc->out_msg) && !ipc->disconnect;
}