static int insertNewKeyValue()

in src/map.c [307:338]


static int insertNewKeyValue(MAP_HANDLE_DATA* handleData, const char* key, const char* value)
{
    int result;
    if (Map_IncreaseStorageKeysValues(handleData) != 0) /*this increases handleData->count*/
    {
        result = MU_FAILURE;
    }
    else
    {
        if ((handleData->keys[handleData->count - 1] = sprintf_char("%s", key)) == NULL)
        {
            Map_DecreaseStorageKeysValues(handleData);
            LogError("unable to mallocAndStrcpy_s");
            result = MU_FAILURE;
        }
        else
        {
            if((handleData->values[handleData->count - 1] = sprintf_char("%s", value)) == NULL)
            {
                free(handleData->keys[handleData->count - 1]);
                Map_DecreaseStorageKeysValues(handleData);
                LogError("unable to mallocAndStrcpy_s");
                result = MU_FAILURE;
            }
            else
            {
                result = 0;
            }
        }
    }
    return result;
}