MCPcopy Create free account
hub / github.com/CloverHackyColor/CloverBootloader / newStringForStringTableKey

Function newStringForStringTableKey

Trash/stringTable.c:200–234  ·  view source on GitHub ↗

* Returns a new malloc'ed string if one is found * in the string table matching 'key'. Also translates * \n escapes in the string. */

Source from the content-addressed store, hash-verified

198 * \n escapes in the string.
199 */
200char *newStringForStringTableKey(
201 char *table,
202 char *key
203)
204{
205 char *val, *newstr, *p;
206 INTN size;
207
208 if (getValueForStringTableKey(table, key, &val, &size)) {
209 newstr = malloc(size+1);
210 for (p = newstr; size; size--, p++, val++) {
211 if ((*p = *val) == '\\') {
212 switch (*++val) {
213 case 'r':
214 *p = '\r';
215 break;
216 case 'n':
217 *p = '\n';
218 break;
219 case 't':
220 *p = '\t';
221 break;
222 default:
223 *p = *val;
224 break;
225 }
226 size--;
227 }
228 }
229 *p = '\0';
230 return newstr;
231 } else {
232 return 0;
233 }
234}
235
236char *
237newStringForKey(char *key)

Callers

nothing calls this directly

Calls 2

mallocFunction · 0.50

Tested by

no test coverage detected