int af_alg_do_crypt(const struct af_alg *aas, uint8_t *out, const uint8_t *in, size_t len, int decrypt) { uint32_t op = decrypt ? ALG_OP_DECRYPT : ALG_OP_ENCRYPT; uint8_t cbuf[CMSG_SPACE(sizeof(op))]; struct msghdr msg; struct cmsghdr *cmsg; struct iovec iov; memset(&msg, 0, sizeof(msg)); memset(cbuf, 0, sizeof(cbuf)); msg.msg_control = cbuf; msg.msg_controllen = sizeof(cbuf); cmsg = CMSG_FIRSTHDR(&msg); cmsg->cmsg_level = SOL_ALG; cmsg->cmsg_type = ALG_SET_OP; cmsg->cmsg_len = CMSG_LEN(sizeof(op)); memcpy(CMSG_DATA(cmsg), &op, sizeof(op)); iov.iov_base = (void *)in; iov.iov_len = len; msg.msg_iov = &iov; msg.msg_iovlen = 1; if (sendmsg(aas->fd, &msg, 0) != len) RETFAIL(-errno); if (read(aas->fd, out, len) != len) RETFAIL(-errno); return 0; }
int init_scanline(TTF_Scan_Line *scanline, int base_size) { CHECKPTR(scanline); RETINIT(SUCCESS); scanline->x = malloc(base_size * sizeof(*scanline->x)); CHECKFAIL(scanline->x, warnerr("failed to alloc scanline")); scanline->size_x = base_size; scanline->num_intersections = 0; RETFAIL(free_scanline(scanline)); }
inline BISTREAM2(std::string &v) { size_t len; RETFAIL(in >> len); // FIXME: stack overflow likely char *buf = (char*)alloca(len+1); buf[len] = 0; RETFAIL(in.read_pod(buf, len)); v = buf; return in; }