Update code comments

This commit is contained in:
Ian Barwick
2016-07-12 10:56:31 +09:00
parent eebaef59a3
commit 76681c0850

View File

@@ -5823,7 +5823,9 @@ param_set(const char *param, const char *value)
int c;
int value_len = strlen(value) + 1;
// scan array for param
/*
* Scan array to see if the parameter is already set - if so replace it
*/
for (c = 0; c <= param_count && param_keywords[c] != NULL; c++)
{
if (strcmp(param_keywords[c], param) == 0)
@@ -5831,20 +5833,29 @@ param_set(const char *param, const char *value)
if (param_values[c] != NULL)
pfree(param_values[c]);
param_values[c] = pg_malloc(value_len);
param_values[c] = pg_malloc0(value_len);
strncpy(param_values[c], value, value_len);
return;
}
}
/*
* Parameter not in array - add it and its associated value
*/
if (c < param_count)
{
int param_len = strlen(param) + 1;
param_keywords[c] = pg_malloc(param_len);
param_values[c] = pg_malloc(value_len);
param_keywords[c] = pg_malloc0(param_len);
param_values[c] = pg_malloc0(value_len);
strncpy(param_keywords[c], param, param_len);
strncpy(param_values[c], value, value_len);
}
/*
* It's theoretically possible a parameter couldn't be added as
* the array is full, but it's highly improbable so we won't
* handle it at the moment.
*/
}