void EstEID_mapFree(EstEID_Map map) { if (!map) return; if (map->next) EstEID_mapFree(map->next); free((void *)map->value); free((void *)map->key); free(map); }
void EstEID_freeCerts() { if (certs == NULL) return; for (unsigned int i = 0; i < certs->count; i++) { EstEID_mapFree(certs->certs[i]); } if (certs->certs) free(certs->certs); if (certs->slotIDs) free(certs->slotIDs); free(certs); certs = NULL; }
int main(void) { EstEID_Map map = NULL; assertIntEquals(0, EstEID_mapSize(map)); map = EstEID_mapPut(map, "foo", "bar"); assertNotNull(map); assertIntEquals(1, EstEID_mapSize(map)); map = EstEID_mapPut(map, "foo", "FOO"); assertIntEquals(1, EstEID_mapSize(map)); char *k = strdup("key"); char *v = strdup("value"); map = EstEID_mapPut(map, k, v); free(k); free(v); assertIntEquals(2, EstEID_mapSize(map)); assertStringEquals("value", EstEID_mapGet(map, "key")); assertNull(EstEID_mapGet(map, "xyz")); EstEID_mapFree(map); EstEID_Map m = EstEID_mapPut(NULL, "a", "A"); EstEID_mapPut(m, "b", "B"); EstEID_mapPut(m, "c", "C"); printf("map:\n"); EstEID_mapPrint(stdout, m); EstEID_Map c = EstEID_mapClone(m); EstEID_mapFree(m); printf("clone:\n"); EstEID_mapPrint(stdout, c); EstEID_mapFree(c); }
int main(void) { assertStringEquals("foo", EstEID_jsonString("foo")); assertStringEquals("foo\\\"", EstEID_jsonString("foo\"")); assertStringEquals("foo\\\\", EstEID_jsonString("foo\\")); assertStringEquals("\\n", EstEID_jsonString("\n")); assertStringEquals("foo\\\\bar\\r\\n\\\"test\\\"", EstEID_jsonString("foo\\bar\r\n\"test\"")); EstEID_Map map = NULL; assertStringEquals("{}", EstEID_mapToJson(map)); map = EstEID_mapPut(map, "foo", "bar"); assertStringEquals("{\"foo\": \"bar\"}", EstEID_mapToJson(map)); map = EstEID_mapPut(map, "a\nb", "\"123\""); assertStringEquals("{\"foo\": \"bar\", \"a\\nb\": \"\\\"123\\\"\"}", EstEID_mapToJson(map)); EstEID_mapFree(map); return 0; }
void certDeallocate(CertInstance *obj) { EstEID_mapFree(obj->certInfo); free(obj); }