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

Function agent_json_compact

src/cli/agent_clients.c:1102–1143  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1100}
1101
1102static char *agent_json_compact(const char *data, size_t length) {
1103 char *output = (char *)malloc(length + 1U);
1104 if (!output) {
1105 return NULL;
1106 }
1107 size_t written = 0U;
1108 char quote = '\0';
1109 bool escaped = false;
1110 for (size_t i = 0U; i < length; i++) {
1111 char current = data[i];
1112 if (quote) {
1113 output[written++] = current;
1114 if (escaped) {
1115 escaped = false;
1116 } else if (current == '\\') {
1117 escaped = true;
1118 } else if (current == quote) {
1119 quote = '\0';
1120 }
1121 } else if (current == '"' || current == '\'') {
1122 quote = current;
1123 output[written++] = current;
1124 } else if (isspace((unsigned char)current)) {
1125 continue;
1126 } else if (current == '/' && i + 1U < length && data[i + 1U] == '/') {
1127 i += 2U;
1128 while (i < length && data[i] != '\n') {
1129 i++;
1130 }
1131 } else if (current == '/' && i + 1U < length && data[i + 1U] == '*') {
1132 i += 2U;
1133 while (i + 1U < length && !(data[i] == '*' && data[i + 1U] == '/')) {
1134 i++;
1135 }
1136 i++;
1137 } else {
1138 output[written++] = current;
1139 }
1140 }
1141 output[written] = '\0';
1142 return output;
1143}
1144
1145static bool agent_json_owned(const char *document, size_t start, size_t end,
1146 const char *canonical) {

Callers 1

agent_json_ownedFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected