summaryrefslogtreecommitdiffstats
path: root/ckpem.h
diff options
context:
space:
mode:
authorKamil Dudka <kdudka@redhat.com>2009-08-20 11:04:14 +0200
committerRob Crittenden <rcritten@redhat.com>2009-08-20 10:58:37 -0400
commit99286597662891ac69146fce6590a435331938cd (patch)
treeea9a52d2c65ba57967357cb7b23cdb3967c343dd /ckpem.h
parent6f7f653c5dc2deca95d3453d706ddc4c2eb46e70 (diff)
downloadpemnss-99286597662891ac69146fce6590a435331938cd.zip
pemnss-99286597662891ac69146fce6590a435331938cd.tar.gz
pemnss-99286597662891ac69146fce6590a435331938cd.tar.xz
implement memory management for internal objects
* ckpem.h: Define list objects, add reference counter to internal objects. * pfind.c: Increase object's reference while exporting. Skip already freed objects. * pinst.c (AddObjectIfNeeded): New function providing sharing of internal objects. * pobject.c: Add support for list objects. Implement pem_mdObject_Finalize(). * psession.c (pem_mdSession_CopyObject): Increase reference count only. Signed-off-by: Kamil Dudka <kdudka@redhat.com>
Diffstat (limited to 'ckpem.h')
-rw-r--r--ckpem.h26
1 files changed, 23 insertions, 3 deletions
diff --git a/ckpem.h b/ckpem.h
index 866d0ea..be74843 100644
--- a/ckpem.h
+++ b/ckpem.h
@@ -101,6 +101,17 @@ typedef enum {
pemTrust
} pemObjectType;
+typedef struct pemInternalObjectStr pemInternalObject;
+typedef struct pemObjectListItemStr pemObjectListItem;
+
+/*
+ * singly-linked list of internal objects
+ */
+struct pemObjectListItemStr {
+ pemInternalObject *io;
+ pemObjectListItem *next;
+};
+
/*
* all the various types of objects are abstracted away in cobject and
* cfind as pemInternalObjects.
@@ -121,8 +132,16 @@ struct pemInternalObjectStr {
char *nickname;
NSSCKMDObject mdObject;
CK_SLOT_ID slotID;
+ CK_ULONG gobjIndex;
+ int refCount;
+
+ /* used by pem_mdFindObjects_Next */
+ CK_BBOOL extRef;
+
+ /* If list != NULL, the object contains no useful data except of the list
+ * of slave objects */
+ pemObjectListItem *list;
};
-typedef struct pemInternalObjectStr pemInternalObject;
struct pemTokenStr {
PRBool logged_in;
@@ -221,8 +240,9 @@ PRBool pem_ParseString(const char* inputstring, const char delimiter,
PRBool pem_FreeParsedStrings(PRInt32 numStrings, char** instrings);
pemInternalObject *
-CreateObject(CK_OBJECT_CLASS objClass, pemObjectType type, SECItem *certDER,
- SECItem *keyDER, char *filename, int objid, CK_SLOT_ID slotID);
+AddObjectIfNeeded(CK_OBJECT_CLASS objClass, pemObjectType type,
+ SECItem *certDER, SECItem *keyDER, char *filename, int objid,
+ CK_SLOT_ID slotID);
void pem_DestroyInternalObject (pemInternalObject *io);