Exemple #1
0
/*
 * reg_arr_size: Calculates the length needed for an array to store the data
 *      contained in a pdu_reg struct, including padding to make the array
 *      length divisible by 4 (to fit evenly in 4 byte words).
 * Params: reg = pdu_reg struct containing the data to be stored.
 * Returns: Length needed for an array to store the data, including padding.
 * Notes:
 */
size_t reg_arr_size(pdu_reg reg)
{
    size_t len = sizeof(reg.op)
                + sizeof(reg.name_len)
                + sizeof(reg.tcp_port)
                + strlen(reg.name);
    len += pad_length(len);
    return len;
}
Exemple #2
0
void connect(vertex_t* pred, vertex_t* succ){
    unsigned int* tmp;

    pred->succ_count++;
    posix_memalign( (void *)&tmp, (size_t) ALIGN_CONSTANT, (size_t) pad_length(sizeof(unsigned int)*(pred->succ_count)));
    if(pred->succ_list != NULL){
        memcpy(tmp, pred->succ_list, (pred->succ_count-1)*sizeof(unsigned int));
        free(pred->succ_list);
    }
    pred->succ_list = tmp;
    pred->succ_list[pred->succ_count-1] = succ->index;

    succ->pred_count++;
    posix_memalign( (void *)&tmp, (size_t) ALIGN_CONSTANT, (size_t) pad_length(sizeof(unsigned int)*(succ->pred_count)));
    if(succ->pred_list != NULL){
        memcpy(tmp, succ->pred_list, (succ->pred_count-1)*sizeof(unsigned int));
        free(succ->pred_list);
    }
    succ->pred_list = tmp;
    succ->pred_list[succ->pred_count-1] = pred->index;

}