Files
discount/docheader.c
T
david parsons 5c6115c601 1. Add the new amalloc module, which (if enabled with
--enable-amalloc) replaced malloc and its ilk with
    versions that attempt to maintain a linked list of
    allocated blocks that can be printed to stderr with
    the `adump()` function.

2.  Clean up a couple more places where I leak memory
    during the first level parse.

3.  tweak cstring.h to try to chase down places where
    the C compiler might optimize EXPAND() into producing
    broken code.
2008-04-03 11:22:07 -07:00

44 lines
851 B
C

/*
* docheader -- get values from the document header
*
* Copyright (C) 2007 David L Parsons.
* The redistribution terms are provided in the COPYRIGHT file that must
* be distributed with this source code.
*/
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include "cstring.h"
#include "markdown.h"
#include "amalloc.h"
#define afterdle(t) (T((t)->text) + (t)->dle)
char *
mkd_doc_title(Document *doc)
{
if ( doc && doc->headers )
return afterdle(doc->headers);
return 0;
}
char *
mkd_doc_author(Document *doc)
{
if ( doc && doc->headers && doc->headers->next )
return afterdle(doc->headers->next);
return 0;
}
char *
mkd_doc_date(Document *doc)
{
if ( doc && doc->headers && doc->headers->next && doc->headers->next->next )
return afterdle(doc->headers->next->next);
return 0;
}