summaryrefslogtreecommitdiff
path: root/contents.c
diff options
context:
space:
mode:
authorSimon Tatham <anakin@pobox.com>1999-09-02 12:35:02 +0000
committerSimon Tatham <anakin@pobox.com>1999-09-02 12:35:02 +0000
commitd3c026f08f629659b5efe23fe8bffd3cf9b845f6 (patch)
treee81d86bf7d706e0ac4c7a9a644ab193cd4f03e3c /contents.c
parent5842eaaf51d9045bc0b199f0b5e82dfc614b2e0c (diff)
downloadhalibut-d3c026f08f629659b5efe23fe8bffd3cf9b845f6.zip
halibut-d3c026f08f629659b5efe23fe8bffd3cf9b845f6.tar.gz
halibut-d3c026f08f629659b5efe23fe8bffd3cf9b845f6.tar.bz2
halibut-d3c026f08f629659b5efe23fe8bffd3cf9b845f6.tar.xz
Redo memory allocation to use mknew macro
[originally from svn r214]
Diffstat (limited to 'contents.c')
-rw-r--r--contents.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/contents.c b/contents.c
index c203852..b387906 100644
--- a/contents.c
+++ b/contents.c
@@ -18,13 +18,12 @@ struct numberstate_Tag {
};
numberstate *number_init(void) {
- numberstate *ret = smalloc(sizeof(numberstate));
+ numberstate *ret = mknew(numberstate);
ret->chapternum = 0;
ret->appendixnum = -1;
ret->ischapter = 1;
ret->maxsectlevel = 32;
- ret->sectionlevels = smalloc(ret->maxsectlevel *
- sizeof(*ret->sectionlevels));
+ ret->sectionlevels = mknewa(int, ret->maxsectlevel);
ret->listitem = -1;
return ret;
}
@@ -34,7 +33,7 @@ void number_free(numberstate *state) {
}
static void dotext(word ***wret, wchar_t *text) {
- word *mnewword = smalloc(sizeof(word));
+ word *mnewword = mknew(word);
mnewword->text = ustrdup(text);
mnewword->type = word_Normal;
mnewword->alt = NULL;
@@ -44,7 +43,7 @@ static void dotext(word ***wret, wchar_t *text) {
}
static void dospace(word ***wret) {
- word *mnewword = smalloc(sizeof(word));
+ word *mnewword = mknew(word);
mnewword->text = NULL;
mnewword->type = word_WhiteSpace;
mnewword->alt = NULL;
@@ -109,9 +108,8 @@ word *number_mktext(numberstate *state, int para, int aux, int prev) {
level = (para == para_Heading ? 0 : aux);
if (state->maxsectlevel <= level) {
state->maxsectlevel = level + 32;
- state->sectionlevels = srealloc(state->sectionlevels,
- state->maxsectlevel *
- sizeof(*state->sectionlevels));
+ state->sectionlevels = resize(state->sectionlevels,
+ state->maxsectlevel);
}
state->sectionlevels[level]++;
for (i = level+1; i < state->maxsectlevel; i++)