MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / toml_declared_table

Function toml_declared_table

src/cli/config_toml_edit.c:1989–2010  ·  view source on GitHub ↗

Declared table `table` (1-based) of the block, or the number of declared * tables in *count when table is 0. */

Source from the content-addressed store, hash-verified

1987/* Declared table `table` (1-based) of the block, or the number of declared
1988 * tables in *count when table is 0. */
1989static int toml_declared_table(const toml_managed_span_t *span, size_t table, size_t *count,
1990 toml_section_t *out) {
1991 size_t pos = span->owned_first;
1992 size_t index = 0U;
1993 while (pos < span->owned_len) {
1994 toml_section_t declared;
1995 if (++index > TOML_MANAGED_MAX_TABLES ||
1996 toml_section_at(span->owned, pos, span->owned_len, &declared) != TOML_EDIT_OK) {
1997 return TOML_EDIT_ERR;
1998 }
1999 if (index == table) {
2000 *out = declared;
2001 return TOML_EDIT_OK;
2002 }
2003 pos = declared.end;
2004 toml_header_dispose(&declared.header);
2005 }
2006 if (count) {
2007 *count = index;
2008 }
2009 return table == 0U ? TOML_EDIT_OK : TOML_EDIT_ERR;
2010}
2011
2012/* Classify one span header. seen[] marks the declared tables the span has
2013 * already supplied, so a second copy is refused instead of guessed at. */

Callers 3

toml_append_user_linesFunction · 0.85
toml_managed_rewriteFunction · 0.85

Calls 2

toml_section_atFunction · 0.85
toml_header_disposeFunction · 0.85

Tested by

no test coverage detected