annotate Modules/_sqlite/cache.h @ 80661:94de77bd0b4b 2.7

Issue #16194: document imp.load_dynamic problems when read several extension modules from the same binary object file.
author Andrew Svetlov <andrew.svetlov@gmail.com>
date Thu, 29 Nov 2012 19:51:28 +0200
parents 04d3ae52ff73
children e9cd15d539e1
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
37362
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
1 /* cache.h - definitions for the LRU cache
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
2 *
59362
04d3ae52ff73 Merged code from pysqlite 2.6.0.
Gerhard Häring <gh@ghaering.de>
parents: 46178
diff changeset
3 * Copyright (C) 2004-2010 Gerhard Häring <gh@ghaering.de>
37362
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
4 *
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
5 * This file is part of pysqlite.
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
6 *
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
7 * This software is provided 'as-is', without any express or implied
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
8 * warranty. In no event will the authors be held liable for any damages
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
9 * arising from the use of this software.
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
10 *
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
11 * Permission is granted to anyone to use this software for any purpose,
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
12 * including commercial applications, and to alter it and redistribute it
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
13 * freely, subject to the following restrictions:
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
14 *
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
15 * 1. The origin of this software must not be misrepresented; you must not
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
16 * claim that you wrote the original software. If you use this software
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
17 * in a product, an acknowledgment in the product documentation would be
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
18 * appreciated but is not required.
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
19 * 2. Altered source versions must be plainly marked as such, and must not be
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
20 * misrepresented as being the original software.
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
21 * 3. This notice may not be removed or altered from any source distribution.
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
22 */
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
23
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
24 #ifndef PYSQLITE_CACHE_H
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
25 #define PYSQLITE_CACHE_H
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
26 #include "Python.h"
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
27
37938
7da4af95ebad Updated the sqlite3 module to the external pysqlite 2.2.2 version.
Gerhard Häring <gh@ghaering.de>
parents: 37362
diff changeset
28 /* The LRU cache is implemented as a combination of a doubly-linked with a
7da4af95ebad Updated the sqlite3 module to the external pysqlite 2.2.2 version.
Gerhard Häring <gh@ghaering.de>
parents: 37362
diff changeset
29 * dictionary. The list items are of type 'Node' and the dictionary has the
7da4af95ebad Updated the sqlite3 module to the external pysqlite 2.2.2 version.
Gerhard Häring <gh@ghaering.de>
parents: 37362
diff changeset
30 * nodes as values. */
7da4af95ebad Updated the sqlite3 module to the external pysqlite 2.2.2 version.
Gerhard Häring <gh@ghaering.de>
parents: 37362
diff changeset
31
40625
b9d4ced23506 Merged changes from standalone version 2.3.3. This should probably all be
Gerhard Häring <gh@ghaering.de>
parents: 37938
diff changeset
32 typedef struct _pysqlite_Node
37362
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
33 {
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
34 PyObject_HEAD
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
35 PyObject* key;
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
36 PyObject* data;
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
37 long count;
40625
b9d4ced23506 Merged changes from standalone version 2.3.3. This should probably all be
Gerhard Häring <gh@ghaering.de>
parents: 37938
diff changeset
38 struct _pysqlite_Node* prev;
b9d4ced23506 Merged changes from standalone version 2.3.3. This should probably all be
Gerhard Häring <gh@ghaering.de>
parents: 37938
diff changeset
39 struct _pysqlite_Node* next;
b9d4ced23506 Merged changes from standalone version 2.3.3. This should probably all be
Gerhard Häring <gh@ghaering.de>
parents: 37938
diff changeset
40 } pysqlite_Node;
37362
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
41
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
42 typedef struct
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
43 {
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
44 PyObject_HEAD
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
45 int size;
37938
7da4af95ebad Updated the sqlite3 module to the external pysqlite 2.2.2 version.
Gerhard Häring <gh@ghaering.de>
parents: 37362
diff changeset
46
7da4af95ebad Updated the sqlite3 module to the external pysqlite 2.2.2 version.
Gerhard Häring <gh@ghaering.de>
parents: 37362
diff changeset
47 /* a dictionary mapping keys to Node entries */
37362
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
48 PyObject* mapping;
37938
7da4af95ebad Updated the sqlite3 module to the external pysqlite 2.2.2 version.
Gerhard Häring <gh@ghaering.de>
parents: 37362
diff changeset
49
7da4af95ebad Updated the sqlite3 module to the external pysqlite 2.2.2 version.
Gerhard Häring <gh@ghaering.de>
parents: 37362
diff changeset
50 /* the factory callable */
37362
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
51 PyObject* factory;
37938
7da4af95ebad Updated the sqlite3 module to the external pysqlite 2.2.2 version.
Gerhard Häring <gh@ghaering.de>
parents: 37362
diff changeset
52
40625
b9d4ced23506 Merged changes from standalone version 2.3.3. This should probably all be
Gerhard Häring <gh@ghaering.de>
parents: 37938
diff changeset
53 pysqlite_Node* first;
b9d4ced23506 Merged changes from standalone version 2.3.3. This should probably all be
Gerhard Häring <gh@ghaering.de>
parents: 37938
diff changeset
54 pysqlite_Node* last;
37938
7da4af95ebad Updated the sqlite3 module to the external pysqlite 2.2.2 version.
Gerhard Häring <gh@ghaering.de>
parents: 37362
diff changeset
55
7da4af95ebad Updated the sqlite3 module to the external pysqlite 2.2.2 version.
Gerhard Häring <gh@ghaering.de>
parents: 37362
diff changeset
56 /* if set, decrement the factory function when the Cache is deallocated.
7da4af95ebad Updated the sqlite3 module to the external pysqlite 2.2.2 version.
Gerhard Häring <gh@ghaering.de>
parents: 37362
diff changeset
57 * this is almost always desirable, but not in the pysqlite context */
37362
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
58 int decref_factory;
40625
b9d4ced23506 Merged changes from standalone version 2.3.3. This should probably all be
Gerhard Häring <gh@ghaering.de>
parents: 37938
diff changeset
59 } pysqlite_Cache;
37362
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
60
40625
b9d4ced23506 Merged changes from standalone version 2.3.3. This should probably all be
Gerhard Häring <gh@ghaering.de>
parents: 37938
diff changeset
61 extern PyTypeObject pysqlite_NodeType;
b9d4ced23506 Merged changes from standalone version 2.3.3. This should probably all be
Gerhard Häring <gh@ghaering.de>
parents: 37938
diff changeset
62 extern PyTypeObject pysqlite_CacheType;
37362
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
63
40625
b9d4ced23506 Merged changes from standalone version 2.3.3. This should probably all be
Gerhard Häring <gh@ghaering.de>
parents: 37938
diff changeset
64 int pysqlite_node_init(pysqlite_Node* self, PyObject* args, PyObject* kwargs);
b9d4ced23506 Merged changes from standalone version 2.3.3. This should probably all be
Gerhard Häring <gh@ghaering.de>
parents: 37938
diff changeset
65 void pysqlite_node_dealloc(pysqlite_Node* self);
37362
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
66
40625
b9d4ced23506 Merged changes from standalone version 2.3.3. This should probably all be
Gerhard Häring <gh@ghaering.de>
parents: 37938
diff changeset
67 int pysqlite_cache_init(pysqlite_Cache* self, PyObject* args, PyObject* kwargs);
b9d4ced23506 Merged changes from standalone version 2.3.3. This should probably all be
Gerhard Häring <gh@ghaering.de>
parents: 37938
diff changeset
68 void pysqlite_cache_dealloc(pysqlite_Cache* self);
b9d4ced23506 Merged changes from standalone version 2.3.3. This should probably all be
Gerhard Häring <gh@ghaering.de>
parents: 37938
diff changeset
69 PyObject* pysqlite_cache_get(pysqlite_Cache* self, PyObject* args);
37362
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
70
40625
b9d4ced23506 Merged changes from standalone version 2.3.3. This should probably all be
Gerhard Häring <gh@ghaering.de>
parents: 37938
diff changeset
71 int pysqlite_cache_setup_types(void);
37362
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
72
e546274d6503 merged the sqlite-integration branch.
Anthony Baxter <anthonybaxter@gmail.com>
parents:
diff changeset
73 #endif