int internal_log_context_init_from_parent()

in v2/src/log_context.c [56:92]


int internal_log_context_init_from_parent(LOG_CONTEXT_HANDLE dest_log_context, LOG_CONTEXT_HANDLE parent_log_context)
{
    int result;

    /* Copy all the pairs from the parent */
    if (parent_log_context != NULL)
    {
        size_t prop_copy_index;
        for (prop_copy_index = 0; prop_copy_index < parent_log_context->property_value_pair_count; prop_copy_index++)
        {
            dest_log_context->property_value_pairs_ptr[prop_copy_index + 1].name = parent_log_context->property_value_pairs_ptr[prop_copy_index].name;
            dest_log_context->property_value_pairs_ptr[prop_copy_index + 1].type = parent_log_context->property_value_pairs_ptr[prop_copy_index].type;

            dest_log_context->property_value_pairs_ptr[prop_copy_index + 1].value = (void*)(dest_log_context->values_data + 1 + ((uint8_t*)parent_log_context->property_value_pairs_ptr[prop_copy_index].value - parent_log_context->values_data));
            if (dest_log_context->property_value_pairs_ptr[prop_copy_index + 1].type->copy(dest_log_context->property_value_pairs_ptr[prop_copy_index + 1].value, parent_log_context->property_value_pairs_ptr[prop_copy_index].value) != 0)
            {
                (void)printf("Error copying property value/pair %zu\r\n", prop_copy_index);
                break;
            }
        }

        if (prop_copy_index < parent_log_context->property_value_pair_count)
        {
            result = MU_FAILURE;
        }
        else
        {
            result = 0;
        }
    }
    else
    {
        result = 0;
    }

    return result;
}