2
* See the file LICENSE for redistribution information.
4
* Copyright (c) 1997-2002
5
* Sleepycat Software. All rights reserved.
10
#ifndef _JAVA_LOCKED_H_
11
#define _JAVA_LOCKED_H_
14
* Used as argument to locked_dbt_get().
16
typedef enum _OpKind {
17
inOp, /* setting data in database (passing data in) */
18
outOp, /* getting data from database to user memory */
19
inOutOp /* both getting/setting data */
25
* A stack variable LOCKED_DBT should be declared for each Dbt used in a
26
* native call to the DB API. Before the DBT can be used, locked_dbt_get()
27
* must be called to temporarily convert any java array found in the
28
* Dbt (which has a pointer to a DBT_JAVAINFO struct) to actual bytes
29
* in memory that remain locked in place. These bytes are used during
30
* the call to the DB C API, and are released and/or copied back when
31
* locked_dbt_put is called.
33
typedef struct _locked_dbt
35
/* these are accessed externally to locked_dbt_ functions */
36
DBT_JAVAINFO *javainfo;
37
unsigned int java_array_len;
40
/* these are for used internally by locked_dbt_ functions */
45
#define LOCKED_ERROR 0x01 /* error occurred */
46
#define LOCKED_CREATE_DATA 0x02 /* must create data on the fly */
47
#define LOCKED_REALLOC_NONNULL 0x04 /* DB_DBT_REALLOC flag, nonnull data */
51
/* Fill the LOCKED_DBT struct and lock the Java byte array */
52
extern int locked_dbt_get(LOCKED_DBT *, JNIEnv *, DB_ENV *, jobject, OpKind);
54
/* unlock the Java byte array */
55
extern void locked_dbt_put(LOCKED_DBT *, JNIEnv *, DB_ENV *);
57
/* realloc the Java byte array */
58
extern int locked_dbt_realloc(LOCKED_DBT *, JNIEnv *, DB_ENV *);
63
* A LOCKED_STRING exists temporarily to convert a java jstring object
64
* to a char *. Because the memory for the char * string is
65
* managed by the JVM, it must be released when we are done
66
* looking at it. Typically, locked_string_get() is called at the
67
* beginning of a function for each jstring object, and locked_string_put
68
* is called at the end of each function for each LOCKED_STRING.
70
typedef struct _locked_string
72
/* this accessed externally to locked_string_ functions */
75
/* this is used internally by locked_string_ functions */
79
extern int locked_string_get(LOCKED_STRING *, JNIEnv *jnienv, jstring jstr);
80
extern void locked_string_put(LOCKED_STRING *, JNIEnv *jnienv); /* this unlocks and frees mem */
82
#endif /* !_JAVA_LOCKED_H_ */