summaryrefslogtreecommitdiff
path: root/dist/api_config.py
diff options
context:
space:
mode:
authorKeith Bostic <keith@wiredtiger.com>2013-04-11 15:58:42 -0400
committerKeith Bostic <keith@wiredtiger.com>2013-04-11 15:58:42 -0400
commit5488e656fa88b46ac187cef6533a6e4cb3cc62cc (patch)
tree9377cb34d9852a5d1872f81b3f3814bdac5e70c0 /dist/api_config.py
parentdb2ce0c4e6dbef194573c40d600e1ed3e7cc8835 (diff)
downloadmongo-5488e656fa88b46ac187cef6533a6e4cb3cc62cc.tar.gz
More work on data-source configuration support.
We can't stack a random set of entries into a cfg[] because we don't want to allocate memory in the API. Instead, whenever a method's arguments are reconfigured, re-build the base configuration string by appending the new configuration, and re-build the checks array, that way we always have a single base configuration string and a single checks array. Re-work how we're handling lists, we can't expect the application to crack them, they can be seriously messy. If it's a list, create an array of NULL-terminated refrences to nul-terminated strings (create an "argv" array, in other words). It's ugly, and the user has to free the memory, but I don't see an alternative.
Diffstat (limited to 'dist/api_config.py')
-rw-r--r--dist/api_config.py41
1 files changed, 31 insertions, 10 deletions
diff --git a/dist/api_config.py b/dist/api_config.py
index 0b56cc41d54..1b163149bcf 100644
--- a/dist/api_config.py
+++ b/dist/api_config.py
@@ -251,10 +251,9 @@ for name in sorted(api_data.methods.keys()):
max(1, 6 - int ((len('WT_CONFIG_ENTRY_' + name)) / 8)) + \
"%2s" % str(slot) + '\n'
- # Write the method name, the uri and the value.
+ # Write the method name and base.
tfile.write('''
\t{ "%(name)s",
-\t NULL,
%(config)s,''' % {
'config' : '\n'.join('\t "%s"' % line
for line in w.wrap(','.join('%s=%s' % (c.name, get_default(c))
@@ -269,23 +268,45 @@ for name in sorted(api_data.methods.keys()):
else:
tfile.write('NULL')
- # Write the extended reference, always NULL initially, this slot is
- # used when the information is extended at run-time.
- tfile.write(',\n\t NULL\n\t},')
+ tfile.write('\n\t},')
# Write a NULL as a terminator for iteration.
-tfile.write('\n\t{ NULL, NULL, NULL, NULL, NULL }')
+tfile.write('\n\t{ NULL, NULL, NULL }')
tfile.write('\n};\n')
# Write the routine that connects the WT_CONNECTION_IMPL structure to the list
# of configuration entry structures.
tfile.write('''
-void
+int
__wt_conn_config_init(WT_SESSION_IMPL *session)
{
- S2C(session)->config_entries = config_entries;
- S2C(session)->config_entries_count =
- sizeof(config_entries)/sizeof(config_entries[0]);
+\tWT_CONNECTION_IMPL *conn;
+\tconst WT_CONFIG_ENTRY *ep, **epp;
+
+\tconn = S2C(session);
+
+\t/* Build a list of pointers to the configuration information. */
+\tWT_RET(__wt_calloc_def(session,
+\t sizeof(config_entries) / sizeof(config_entries[0]), &epp));
+\tconn->config_entries = epp;
+
+\t/* Fill in the list to reference the default information. */
+\tfor (ep = config_entries;;) {
+\t\t*epp++ = ep++;
+\t\tif (ep->method == NULL)
+\t\t\tbreak;
+\t}
+\treturn (0);
+}
+
+void
+__wt_conn_config_discard(WT_SESSION_IMPL *session)
+{
+\tWT_CONNECTION_IMPL *conn;
+
+\tconn = S2C(session);
+
+\t__wt_free(session, conn->config_entries);
}
''')