1/*-
2 * See the file LICENSE for redistribution information.
3 *
4 * Copyright (c) 1999,2008 Oracle.  All rights reserved.
5 *
6 * $Id: globals.c,v 1.6 2008/01/08 20:58:44 bostic Exp $
7 */
8
9#include "db_config.h"
10
11#include "db_int.h"
12
13/*
14 * brew_bdb_begin --
15 *	Initialize the BREW port of Berkeley DB.
16 */
17int
18brew_bdb_begin()
19{
20	void *p;
21
22	/*
23	 * The BREW ARM compiler can't handle statics or globals, so we have
24	 * store them off the AEEApplet and initialize them in in-line code.
25	 */
26	p = ((BDBApp *)GETAPPINSTANCE())->db_global_values;
27	if (p == NULL) {
28		if ((p = malloc(sizeof(DB_GLOBALS))) == NULL)
29			return (ENOMEM);
30		memset(p, 0, sizeof(DB_GLOBALS));
31
32		((BDBApp *)GETAPPINSTANCE())->db_global_values = p;
33
34		TAILQ_INIT(&DB_GLOBAL(envq));
35		DB_GLOBAL(db_line) =
36		    "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=";
37	}
38	return (0);
39}
40
41/*
42 * brew_bdb_end --
43 *	Close down the BREW port of Berkeley DB.
44 */
45void
46brew_bdb_end()
47{
48	void *p;
49
50	p = ((BDBApp *)GETAPPINSTANCE())->db_global_values;
51
52	free(p);
53}
54