From 5b403723fdd074e1b510aa4fbe1e2685fda156e3 Mon Sep 17 00:00:00 2001 From: Sebastian Hammer Date: Wed, 28 Sep 1994 12:56:09 +0000 Subject: [PATCH] Added access functions (ISPT) --- include/isam.h | 7 +++++-- isam/isam.c | 49 ++++++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 51 insertions(+), 5 deletions(-) diff --git a/include/isam.h b/include/isam.h index 2ad05ee..4febc17 100644 --- a/include/isam.h +++ b/include/isam.h @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: isam.h,v $ - * Revision 1.7 1994-09-28 11:56:13 quinn + * Revision 1.8 1994-09-28 12:56:09 quinn + * Added access functions (ISPT) + * + * Revision 1.7 1994/09/28 11:56:13 quinn * Removed const from input to is_merge * * Revision 1.6 1994/09/28 11:29:28 quinn @@ -74,7 +77,7 @@ typedef struct isam_struct typedef struct ispt_struct { - struct is_mtable *tab; + struct is_mtable tab; struct ispt_struct *next; /* freelist */ } ispt_struct, *ISPT; diff --git a/isam/isam.c b/isam/isam.c index 7fee014..98a1f01 100644 --- a/isam/isam.c +++ b/isam/isam.c @@ -4,7 +4,10 @@ * Sebastian Hammer, Adam Dickmeiss * * $Log: isam.c,v $ - * Revision 1.8 1994-09-28 12:32:17 quinn + * Revision 1.9 1994-09-28 12:56:15 quinn + * Added access functions (ISPT) + * + * Revision 1.8 1994/09/28 12:32:17 quinn * Trivial * * Revision 1.7 1994/09/28 11:56:25 quinn @@ -40,6 +43,27 @@ #include "keyops.h" static int (*extcmp)(const void *p1, const void *p2); +static ispt_struct *ispt_freelist = 0; + +static ISPT ispt_alloc() +{ + ISPT p; + + if (ispt_freelist) + { + p = ispt_freelist; + ispt_freelist = ispt_freelist->next; + } + else + p = xmalloc(sizeof(ispt_struct)); + return p; +} + +static void ispt_free(ISPT pt) +{ + pt->next = ispt_freelist; + ispt_freelist = pt; +} static int splitargs(const char *s, char *bf[], int max) { @@ -389,9 +413,28 @@ ISAM_P is_merge(ISAM is, ISAM_P pos, int num, char *data) * Locate a table of keys in an isam file. The ISPT is an individual * position marker for that table. */ -ISPT is_position(ISAM is, ISAM_P pos); +ISPT is_position(ISAM is, ISAM_P pos) +{ + ispt_struct *p; + + p = ispt_alloc(); + is_m_establish_tab(is, &p->tab, pos); + return p; +} /* * Release ISPT. */ -void is_pt_free(ISPT ip); +void is_pt_free(ISPT ip) +{ + is_m_release_tab(&ip->tab); + ispt_free(ip); +} + +/* + * Read a key from a table. + */ +int is_readkey(ISPT ip, void *buf) +{ + return is_m_read_record(&ip->tab, buf); +} -- 1.7.10.4