summaryrefslogtreecommitdiff
path: root/index.c
diff options
context:
space:
mode:
authorSimon Tatham <anakin@pobox.com>2004-06-12 20:31:03 +0000
committerSimon Tatham <anakin@pobox.com>2004-06-12 20:31:03 +0000
commita5d800d080a9eb557082042216636ac872eac7ec (patch)
treebbc892a5a4e1da173dbbbe4358160aec96b4161d /index.c
parent3ae295ca676ac0db275ad2cc1945fa0eca4a19bd (diff)
downloadhalibut-a5d800d080a9eb557082042216636ac872eac7ec.zip
halibut-a5d800d080a9eb557082042216636ac872eac7ec.tar.gz
halibut-a5d800d080a9eb557082042216636ac872eac7ec.tar.bz2
halibut-a5d800d080a9eb557082042216636ac872eac7ec.tar.xz
Switch the memory allocation macros from the Halibut ones
(mknew/mknewa/resize) to the PuTTY ones (snew/snewn/sresize). snewn and mknewa have their arguments opposite ways round; this may make the change initially painful but in the long term will free me of a nasty context switch every time I move between codebases. Also sresize takes an explicit type operand which is used to cast the return value from realloc, thus enforcing that it must be correct, and arranging that if anyone tries to compile Halibut with a C++ compiler there should be a lot less pain. [originally from svn r4276]
Diffstat (limited to 'index.c')
-rw-r--r--index.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/index.c b/index.c
index 9a2d9df..5dde59f 100644
--- a/index.c
+++ b/index.c
@@ -10,14 +10,14 @@ static int compare_tags(void *av, void *bv);
static int compare_entries(void *av, void *bv);
indexdata *make_index(void) {
- indexdata *ret = mknew(indexdata);
+ indexdata *ret = snew(indexdata);
ret->tags = newtree234(compare_tags);
ret->entries = newtree234(compare_entries);
return ret;
}
static indextag *make_indextag(void) {
- indextag *ret = mknew(indextag);
+ indextag *ret = snew(indextag);
ret->name = NULL;
ret->implicit_text = NULL;
ret->explicit_texts = NULL;
@@ -131,10 +131,10 @@ void index_merge(indexdata *idx, int is_explicit, wchar_t *tags, word *text,
}
if (t->nexplicit >= t->explicit_size) {
t->explicit_size = t->nexplicit + 8;
- t->explicit_texts = resize(t->explicit_texts,
- t->explicit_size);
- t->explicit_fpos = resize(t->explicit_fpos,
- t->explicit_size);
+ t->explicit_texts = sresize(t->explicit_texts,
+ t->explicit_size, word *);
+ t->explicit_fpos = sresize(t->explicit_fpos,
+ t->explicit_size, filepos);
}
t->explicit_texts[t->nexplicit] = text;
t->explicit_fpos[t->nexplicit] = *fpos;
@@ -169,9 +169,9 @@ void build_index(indexdata *i) {
fa = t->explicit_fpos;
}
if (t->nrefs) {
- t->refs = mknewa(indexentry *, t->nrefs);
+ t->refs = snewn(t->nrefs, indexentry *);
for (j = 0; j < t->nrefs; j++) {
- indexentry *ent = mknew(indexentry);
+ indexentry *ent = snew(indexentry);
ent->text = *ta++;
ent->fpos = *fa++;
t->refs[j] = add234(i->entries, ent);