Take out the T(x) hack from mkd_css() & mkd_xml() and instead

strdup() to return free()able memory.
This commit is contained in:
david parsons
2017-01-22 00:02:28 -08:00
parent 9d0de94005
commit 2ebcb044d2
2 changed files with 11 additions and 12 deletions
+5 -7
View File
@@ -54,15 +54,13 @@ mkd_css(Document *d, char **res)
stylesheets(d->code, &f);
if ( (size = S(f)) > 0 ) {
/* null-terminate, then strdup() into a free()able memory
* chunk
*/
EXPAND(f) = 0;
/* HACK ALERT! HACK ALERT! HACK ALERT! */
*res = T(f);/* we know that a T(Cstring) is a character pointer */
/* so we can simply pick it up and carry it away, */
/* leaving the husk of the Ctring on the stack */
/* END HACK ALERT */
*res = strdup(T(f));
}
else
DELETE(f);
DELETE(f);
return size;
}
return EOF;
+6 -5
View File
@@ -74,9 +74,10 @@ mkd_xml(char *p, int size, char **res)
else
Csputc(c, &f);
}
/* HACK ALERT! HACK ALERT! HACK ALERT! */
*res = T(f); /* we know that a T(Cstring) is a character pointer */
/* so we can simply pick it up and carry it away, */
return S(f); /* leaving the husk of the Ctring on the stack */
/* END HACK ALERT */
/* null terminate, strdup() into a free()able memory block,
* and return the size of everything except the null terminator
*/
EXPAND(f) = 0;
*res = strdup(T(f));
return S(f)-1;
}