* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
* OF THIS SOFTWARE.
*
- * $Id: oid.h,v 1.2 1999-12-16 23:36:19 adam Exp $
+ * $Id: oid.h,v 1.3 2000-01-06 14:59:13 adam Exp $
*/
#ifndef OID_H
YAZ_EXPORT struct oident *oid_addent (int *oid, enum oid_proto proto,
enum oid_class oclass,
const char *desc, int value);
+YAZ_EXPORT void oid_init(void);
+YAZ_EXPORT void oid_exit(void);
#ifdef __cplusplus
}
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: nmem.c,v $
- * Revision 1.19 1999-11-30 13:47:12 adam
+ * Revision 1.20 2000-01-06 14:59:13 adam
+ * Added oid_init/oid_exit. Changed oid_exit.
+ *
+ * Revision 1.19 1999/11/30 13:47:12 adam
* Improved installation. Moved header files to include/yaz.
*
* Revision 1.18 1999/08/27 09:40:32 adam
cfreelist = cfreelist->next;
xfree (cfl);
}
+ nmem_init_flag = 0;
#ifdef WIN32
DeleteCriticalSection(&critical_section);
#endif
* Sebastian Hammer, Adam Dickmeiss
*
* $Log: oid.c,v $
- * Revision 1.39 1999-12-16 23:36:19 adam
+ * Revision 1.40 2000-01-06 14:59:13 adam
+ * Added oid_init/oid_exit. Changed oid_exit.
+ *
+ * Revision 1.39 1999/12/16 23:36:19 adam
* Implemented ILL protocol. Minor updates ASN.1 compiler.
*
* Revision 1.38 1999/11/30 13:47:12 adam
static struct oident_list *oident_table = NULL;
static int oid_value_dynamic = VAL_DYNAMIC;
+static int oid_init_flag = 0;
/*
* OID database
}
}
-static void oid_init (void)
+void oid_init (void)
{
- static int checked = 0;
-
- if (checked)
+ if (oid_init_flag)
return;
+ /* oid_transfer is thread safe, so there's nothing wrong in having
+ two threads calling it simultaniously. On the other hand
+ no thread may exit oid_init before all OID's bave been
+ transferred - which is why checked is set after oid_transfer...
+ */
oid_transfer (oids);
- checked = 1;
+ oid_init_flag = 1;
}
+void oid_exit (void)
+{
+ while (oident_table)
+ {
+ struct oident_list *this_p = oident_table;
+ oident_table = oident_table->next;
+
+ xfree (this_p->oident.desc);
+ xfree (this_p);
+ }
+ oid_init_flag = 0;
+}
static struct oident *oid_getentbyoid_x(int *o)
{
{
char desc_str[200];
struct oident_list *oident_list;
- oident_list = (struct oident_list *) malloc (sizeof(*oident_list));
+ oident_list = (struct oident_list *) xmalloc (sizeof(*oident_list));
oident = &oident_list->oident;
oident->proto = proto;
oident->oclass = oclass;
sprintf (desc_str+strlen(desc_str), ".%d", oid[i]);
desc = desc_str;
}
- oident->desc = (char *) malloc (strlen(desc)+1);
+ oident->desc = (char *) xmalloc (strlen(desc)+1);
strcpy (oident->desc, desc);
if (value == VAL_DYNAMIC)
oident->value = (enum oid_value) (++oid_value_dynamic);