static size_t indexHtmlSize = 0; static char* indexHtml = NULL; #define sb_concatf(fmt, ...) \ if ((sbc - sbi) < 1024) { \ sbc *= 1.5; \ stringBuffer = realloc(stringBuffer, sbc); \ } \ if ((result = snprintf(stringBuffer + sbi, sbc - sbi, fmt, ##__VA_ARGS__)) > 0) sbi += result; \ else die("fatal error concating to string"); static void outputHtml() { static int sbi = 0; static int sbc = 50 * 1024; static char* stringBuffer = NULL; if (stringBuffer == NULL) stringBuffer = malloc(sizeof(char) * sbc); if (indexHtml == NULL) indexHtml = readWholeFile("base-index.html", &indexHtmlSize); int result = 0; sb_concatf("%s", indexHtml); for (int i = 0; i < numAllStructs; i++) { struct StructInfo *structInfo = allStructs + i; printStructInfo(structInfo); ssize_t byteCounter = 0; sb_concatf( "