3
Copyright (c) 2006-2007, BBR Inc. All rights reserved.
5
Permission is hereby granted, free of charge, to any person obtaining
6
a copy of this software and associated documentation files (the
7
"Software"), to deal in the Software without restriction, including
8
without limitation the rights to use, copy, modify, merge, publish,
9
distribute, sublicense, and/or sell copies of the Software, and to
10
permit persons to whom the Software is furnished to do so, subject to
11
the following conditions:
13
The above copyright notice and this permission notice shall be included
14
in all copies or substantial portions of the Software.
16
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
33
#include "P2PObject.h"
36
/* orginal number hash table size. should be 2^n */
37
#define ORGTABLESIZE 4096
39
P2PObject **P2PObject::orgTable = 0;
41
int P2PObject::hash(int orgNumA, int orgGenA)
43
return orgNumA & (ORGTABLESIZE-1);
49
/* first time, alloc table */
50
orgTable = new P2PObject *[ORGTABLESIZE];
51
memset(orgTable,0,ORGTABLESIZE*sizeof(P2PObject *));
54
if (orgNum > 0 && orgGen >=0) {
55
/* put this into hashtable */
56
int hv = hash(orgNum, orgGen);
59
for (p = &orgTable[hv];*p != 0;p = &((*p)->next));
64
void P2PObject::remove()
66
if (orgNum > 0 && orgGen >=0) {
67
/* remove this from hashtable */
68
int hv = hash(orgNum, orgGen);
71
for (p = &orgTable[hv];*p != 0;p = &((*p)->next)) {
81
P2PObject *P2PObject::find(int orgNumA, int orgGenA)
83
if (orgNumA > 0 && orgGenA >=0) {
84
/* remove this from hashtable */
85
int hv = hash(orgNumA, orgGenA);
88
for (p = orgTable[hv];p != 0;p = p->next) {
89
if (p->orgNum == orgNumA && p->orgGen == orgGenA) {
97
void P2PObject::outputBegin(P2POutputStream *str)
101
P2PXRef::put(this,str);
103
str->printf("%d %d obj\n",num,gen);
106
void P2PObject::outputEnd(P2POutputStream *str)
108
str->puts("endobj\n");
111
void P2PObject::outputRef(P2POutputStream *str)
116
str->printf("%d %d R",num,gen);