int dtls1_buffer_record(SSL *s, record_pqueue *queue, unsigned char *priority)
{
    DTLS1_RECORD_DATA *rdata;
    pitem *item;
    if (pqueue_size(queue->q) >= 100)
        return 0;
    rdata = OPENSSL_malloc(sizeof(*rdata));
    item = pitem_new(priority, rdata);
    if (rdata == NULL || item == NULL) {
        OPENSSL_free(rdata);
        pitem_free(item);
        SSLerr(SSL_F_DTLS1_BUFFER_RECORD, ERR_R_INTERNAL_ERROR);
        return -1;
    }
    rdata->packet = s->rlayer.packet;
    rdata->packet_length = s->rlayer.packet_length;
    memcpy(&(rdata->rbuf), &s->rlayer.rbuf, sizeof(SSL3_BUFFER));
    memcpy(&(rdata->rrec), &s->rlayer.rrec, sizeof(SSL3_RECORD));
    item->data = rdata;
#ifndef OPENSSL_NO_SCTP
    if (BIO_dgram_is_sctp(SSL_get_rbio(s)) &&
        (SSL_get_state(s) == TLS_ST_SR_FINISHED
         || SSL_get_state(s) == TLS_ST_CR_FINISHED)) {
        BIO_ctrl(SSL_get_rbio(s), BIO_CTRL_DGRAM_SCTP_GET_RCVINFO,
                 sizeof(rdata->recordinfo), &rdata->recordinfo);
    }
#endif
    s->rlayer.packet = NULL;
    s->rlayer.packet_length = 0;
    memset(&s->rlayer.rbuf, 0, sizeof(s->rlayer.rbuf));
    memset(&s->rlayer.rrec, 0, sizeof(s->rlayer.rrec));
    if (!ssl3_setup_buffers(s)) {
        SSLerr(SSL_F_DTLS1_BUFFER_RECORD, ERR_R_INTERNAL_ERROR);
        OPENSSL_free(rdata->rbuf.buf);
        OPENSSL_free(rdata);
        pitem_free(item);
        return (-1);
    }
    if (pqueue_insert(queue->q, item) == NULL) {
        SSLerr(SSL_F_DTLS1_BUFFER_RECORD, ERR_R_INTERNAL_ERROR);
        OPENSSL_free(rdata->rbuf.buf);
        OPENSSL_free(rdata);
        pitem_free(item);
        return (-1);
    }
    return (1);
}
['int dtls1_buffer_record(SSL *s, record_pqueue *queue, unsigned char *priority)\n{\n    DTLS1_RECORD_DATA *rdata;\n    pitem *item;\n    if (pqueue_size(queue->q) >= 100)\n        return 0;\n    rdata = OPENSSL_malloc(sizeof(*rdata));\n    item = pitem_new(priority, rdata);\n    if (rdata == NULL || item == NULL) {\n        OPENSSL_free(rdata);\n        pitem_free(item);\n        SSLerr(SSL_F_DTLS1_BUFFER_RECORD, ERR_R_INTERNAL_ERROR);\n        return -1;\n    }\n    rdata->packet = s->rlayer.packet;\n    rdata->packet_length = s->rlayer.packet_length;\n    memcpy(&(rdata->rbuf), &s->rlayer.rbuf, sizeof(SSL3_BUFFER));\n    memcpy(&(rdata->rrec), &s->rlayer.rrec, sizeof(SSL3_RECORD));\n    item->data = rdata;\n#ifndef OPENSSL_NO_SCTP\n    if (BIO_dgram_is_sctp(SSL_get_rbio(s)) &&\n        (SSL_get_state(s) == TLS_ST_SR_FINISHED\n         || SSL_get_state(s) == TLS_ST_CR_FINISHED)) {\n        BIO_ctrl(SSL_get_rbio(s), BIO_CTRL_DGRAM_SCTP_GET_RCVINFO,\n                 sizeof(rdata->recordinfo), &rdata->recordinfo);\n    }\n#endif\n    s->rlayer.packet = NULL;\n    s->rlayer.packet_length = 0;\n    memset(&s->rlayer.rbuf, 0, sizeof(s->rlayer.rbuf));\n    memset(&s->rlayer.rrec, 0, sizeof(s->rlayer.rrec));\n    if (!ssl3_setup_buffers(s)) {\n        SSLerr(SSL_F_DTLS1_BUFFER_RECORD, ERR_R_INTERNAL_ERROR);\n        OPENSSL_free(rdata->rbuf.buf);\n        OPENSSL_free(rdata);\n        pitem_free(item);\n        return (-1);\n    }\n    if (pqueue_insert(queue->q, item) == NULL) {\n        SSLerr(SSL_F_DTLS1_BUFFER_RECORD, ERR_R_INTERNAL_ERROR);\n        OPENSSL_free(rdata->rbuf.buf);\n        OPENSSL_free(rdata);\n        pitem_free(item);\n        return (-1);\n    }\n    return (1);\n}', 'int pqueue_size(pqueue_s *pq)\n{\n    pitem *item = pq->items;\n    int count = 0;\n    while (item != NULL) {\n        count++;\n        item = item->next;\n    }\n    return count;\n}', 'void *CRYPTO_malloc(size_t num, const char *file, int line)\n{\n    void *ret = NULL;\n    if (num <= 0)\n        return NULL;\n    allow_customize = 0;\n#ifndef OPENSSL_NO_CRYPTO_MDEBUG\n    if (call_malloc_debug) {\n        CRYPTO_mem_debug_malloc(NULL, num, 0, file, line);\n        ret = malloc(num);\n        CRYPTO_mem_debug_malloc(ret, num, 1, file, line);\n    } else {\n        ret = malloc(num);\n    }\n#else\n    (void)file;\n    (void)line;\n    ret = malloc(num);\n#endif\n#ifndef OPENSSL_CPUID_OBJ\n    if (ret && (num > 2048)) {\n        extern unsigned char cleanse_ctr;\n        ((unsigned char *)ret)[0] = cleanse_ctr;\n    }\n#endif\n    return ret;\n}', 'pitem *pitem_new(unsigned char *prio64be, void *data)\n{\n    pitem *item = OPENSSL_malloc(sizeof(*item));\n    if (item == NULL)\n        return NULL;\n    memcpy(item->priority, prio64be, sizeof(item->priority));\n    item->data = data;\n    item->next = NULL;\n    return item;\n}']