/** * giop_send_buffer_append_aligned: * @buf: the buffer * @mem: the memory pointer * @align_len: the alignment and length of @mem. * * This routine alignes the send buffer to a byte boundary * of size @align_len, and writes align_len bytes of memory * pointed to by @mem to the buffer, or simply expands the * buffer if mem is NULL by that much. * * Return value: a pointer to the beggining of the * contiguous space available for @mem * * Note: do not assume anything about the physical * alignment of the returned pointer. **/ guchar * giop_send_buffer_append_aligned (GIOPSendBuffer *buf, gconstpointer mem, gulong align_len) { guchar *indirect; /* FIXME: could make this more efficient by in-lining the align more aggressively here */ giop_send_buffer_align (buf, align_len); if (buf->indirect_left < align_len) get_next_indirect (buf, 0); indirect = buf->indirect; if (mem) memcpy (indirect, mem, align_len); else p_memzero (indirect, align_len); giop_send_buffer_append_real (buf, indirect, align_len); buf->indirect += align_len; buf->indirect_left -= align_len; return indirect; }
/** * giop_send_buffer_align: * @buf: the buffer * @boundary: the boundary. * * Appends memory to the SendBuffer to align it to a boundary * of size @boundary bytes - if neccessary. **/ void giop_send_buffer_align (GIOPSendBuffer *buf, gulong boundary) { gulong align_amt, ms; /* 1. Figure out how much to align by */ ms = buf->msg.header.message_size + buf->header_size; align_amt = ALIGN_VALUE(ms, boundary) - ms; /* 2. Do the alignment */ if (align_amt) { if (buf->indirect_left < align_amt) get_next_indirect (buf, 0); p_memzero (buf->indirect, align_amt); giop_send_buffer_append_real (buf, buf->indirect, align_amt); buf->indirect += align_amt; buf->indirect_left -= align_amt; } }
static void genuid_simple (guchar *buffer, int length) { static guint32 inc = 0; g_assert (length >= 4); p_memzero (buffer, length); if (length > 4) memcpy (buffer + 4, &genuid_pid, 4); if (length > 8) memcpy (buffer + 8, &genuid_uid, 4); INC_LOCK (); inc++; memcpy (buffer, &inc, 4); xor_buffer (buffer, length); INC_UNLOCK (); }