mirror of
https://github.com/Orc/discount.git
synced 2026-09-25 04:10:00 +03:00
Take out the T(x) hack from mkd_css() & mkd_xml() and instead
strdup() to return free()able memory.
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user