static void Map_DecreaseStorageKeysValues()

in src/map.c [220:259]


static void Map_DecreaseStorageKeysValues(MAP_HANDLE_DATA* handleData)
{
    if (handleData->count == 1)
    {
        free(handleData->keys);
        handleData->keys = NULL;
        free(handleData->values);
        handleData->values = NULL;
        handleData->count = 0;
        handleData->mapFilterCallback = NULL;
    }
    else
    {
        /*certainly > 1...*/
        char** undoneValues;
        char** undoneKeys = realloc_2(handleData->keys, handleData->count - 1, sizeof(char*));
        if (undoneKeys == NULL)
        {
            LogError("CATASTROPHIC error, realloc_2(handleData->keys, handleData->count=%zu - 1, sizeof(char*)=%zu);",
                handleData->count, sizeof(char*));
        }
        else
        {
            handleData->keys = undoneKeys;
        }

        undoneValues = realloc_2(handleData->values, handleData->count - 1, sizeof(char*));
        if (undoneValues == NULL)
        {
            LogError("CATASTROPHIC error, realloc_2(handleData->values=%p, handleData->count=%zu - 1, sizeof(char*)=%zu);",
                handleData->values, handleData->count, sizeof(char*));
        }
        else
        {
            handleData->values = undoneValues;
        }

        handleData->count--;
    }
}