mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2025-03-03 14:52:21 +02:00
Dynamically allocate index to key index map.
Now the config/config module has no notion of max option indexes. The config/parse still needs the max but this will be removed at a later date.
This commit is contained in:
parent
e4b48eb430
commit
9657f1b325
@ -44,6 +44,7 @@
|
||||
<release-development-list>
|
||||
<release-item>
|
||||
<commit subject="Fix inconsistent group display names in messages."/>
|
||||
<commit subject="Dynamically allocate index to key index map."/>
|
||||
|
||||
<release-item-contributor-list>
|
||||
<release-item-contributor id="david.steele"/>
|
||||
|
@ -12,11 +12,6 @@ The general-purpose functions for querying the current configuration are found i
|
||||
#include "config/config.h"
|
||||
#include "config/parse.h"
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
The maximum number of keys that an indexed option can have, e.g. pg256-path would be the maximum pg-path option
|
||||
***********************************************************************************************************************************/
|
||||
#define CFG_OPTION_KEY_MAX 256
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Configuration data. These structures are not directly user-created or accessible. configParse() creates the structures and uses
|
||||
cfgInit() to load it as the current configuration. Various cfg*() functions provide access.
|
||||
@ -66,7 +61,7 @@ typedef struct Config
|
||||
unsigned int indexTotal; // Total number of indexes with values in option group
|
||||
bool indexDefaultExists; // Is there a default index for non-indexed functions?
|
||||
unsigned int indexDefault; // Default index (usually 0)
|
||||
unsigned int indexMap[CFG_OPTION_KEY_MAX]; // List of index to key index mappings
|
||||
unsigned int *indexMap; // List of index to key index mappings
|
||||
} optionGroup[CFG_OPTION_GROUP_TOTAL];
|
||||
|
||||
// Option data
|
||||
|
@ -26,6 +26,11 @@ Define global section name
|
||||
***********************************************************************************************************************************/
|
||||
#define CFGDEF_SECTION_GLOBAL "global"
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
The maximum number of keys that an indexed option can have, e.g. pg256-path would be the maximum pg-path option
|
||||
***********************************************************************************************************************************/
|
||||
#define CFG_OPTION_KEY_MAX 256
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Section enum - defines which sections of the config an option can appear in
|
||||
***********************************************************************************************************************************/
|
||||
@ -1927,11 +1932,21 @@ configParse(const Storage *storage, unsigned int argListSize, const char *argLis
|
||||
if (!config->optionGroup[groupId].valid)
|
||||
continue;
|
||||
|
||||
// Allocate memory for the index to key index map
|
||||
MEM_CONTEXT_BEGIN(config->memContext)
|
||||
{
|
||||
config->optionGroup[groupId].indexMap = memNew(
|
||||
sizeof(unsigned int) *
|
||||
(config->optionGroup[groupId].indexTotal == 0 ? 1 : config->optionGroup[groupId].indexTotal));
|
||||
}
|
||||
MEM_CONTEXT_END();
|
||||
|
||||
// If no values were found in any index then use index 0 since all valid groups must have at least one index. This
|
||||
// may lead to an error unless all options in the group have defaults but that will be resolved later.
|
||||
if (config->optionGroup[groupId].indexTotal == 0)
|
||||
{
|
||||
config->optionGroup[groupId].indexTotal = 1;
|
||||
config->optionGroup[groupId].indexMap[0] = 0;
|
||||
}
|
||||
// Else write the key to index map for the group. This allows translation from keys to indexes and vice versa.
|
||||
else
|
||||
@ -1945,8 +1960,11 @@ configParse(const Storage *storage, unsigned int argListSize, const char *argLis
|
||||
{
|
||||
optionKeyIdx = 1;
|
||||
optionIdxMax = 1;
|
||||
|
||||
config->optionGroup[groupId].indexMap[0] = 0;
|
||||
}
|
||||
|
||||
// Write keys into the index map
|
||||
for (; optionKeyIdx < CFG_OPTION_KEY_MAX; optionKeyIdx++)
|
||||
{
|
||||
if (groupIdxMap[groupId][optionKeyIdx])
|
||||
|
Loading…
x
Reference in New Issue
Block a user