libidav/pwdstore.c

branch
dav-2
changeset 891
4d58cbcc9efa
parent 889
42cdbf9bbd49
--- a/libidav/pwdstore.c	Sun Dec 07 20:16:59 2025 +0100
+++ b/libidav/pwdstore.c	Fri Dec 19 17:53:18 2025 +0100
@@ -64,7 +64,7 @@
         return NULL;
     }
     
-    CxBuffer *buf = cxBufferCreate(NULL, 2048, cxDefaultAllocator, CX_BUFFER_FREE_CONTENTS|CX_BUFFER_AUTO_EXTEND);
+    CxBuffer *buf = cxBufferCreate(cxDefaultAllocator, NULL, 2048, CX_BUFFER_FREE_CONTENTS|CX_BUFFER_AUTO_EXTEND);
     cx_stream_copy(in, buf, (cx_read_func)fread, (cx_write_func)cxBufferWrite);
     fclose(in);
     
@@ -75,8 +75,8 @@
     
     PwdStore *p = malloc(sizeof(PwdStore));
     p->ids = cxHashMapCreate(cxDefaultAllocator, CX_STORE_POINTERS, 16);
-    p->locations = cxLinkedListCreateSimple(CX_STORE_POINTERS);
-    p->noloc = cxLinkedListCreateSimple(CX_STORE_POINTERS);
+    p->locations = cxLinkedListCreate(NULL, CX_STORE_POINTERS);
+    p->noloc = cxLinkedListCreate(NULL, CX_STORE_POINTERS);
     p->index = cxHashMapCreate(cxDefaultAllocator, CX_STORE_POINTERS, 16);
     p->content = buf;
     p->key = NULL;
@@ -96,10 +96,10 @@
 PwdStore* pwdstore_new(void) {
     PwdStore *p = calloc(1, sizeof(PwdStore));
     p->ids = cxHashMapCreate(cxDefaultAllocator, CX_STORE_POINTERS, 16);
-    p->locations = cxLinkedListCreateSimple(CX_STORE_POINTERS);
-    p->noloc = cxLinkedListCreateSimple(CX_STORE_POINTERS);
+    p->locations = cxLinkedListCreate(NULL, CX_STORE_POINTERS);
+    p->noloc = cxLinkedListCreate(NULL, CX_STORE_POINTERS);
     p->index = cxHashMapCreate(cxDefaultAllocator, CX_STORE_POINTERS, 16);
-    p->content = cxBufferCreate(NULL, PWDS_HEADER_SIZE, cxDefaultAllocator, CX_BUFFER_FREE_CONTENTS|CX_BUFFER_AUTO_EXTEND);
+    p->content = cxBufferCreate(cxDefaultAllocator, NULL, PWDS_HEADER_SIZE, CX_BUFFER_FREE_CONTENTS|CX_BUFFER_AUTO_EXTEND);
     PWDS_MAGIC(p) = PWDS_MAGIC_CHAR;
     PWDS_VERSION(p) = 1;
     PWDS_ENC(p) = DAV_KEY_AES256;
@@ -128,8 +128,8 @@
     
     PwdStore *newp = calloc(1, sizeof(PwdStore));
     newp->ids = cxHashMapCreate(cxDefaultAllocator, CX_STORE_POINTERS, 16);
-    newp->locations = cxLinkedListCreateSimple(CX_STORE_POINTERS);
-    newp->noloc = cxLinkedListCreateSimple(CX_STORE_POINTERS);
+    newp->locations = cxLinkedListCreate(NULL, CX_STORE_POINTERS);
+    newp->noloc = cxLinkedListCreate(NULL, CX_STORE_POINTERS);
     newp->index = cxHashMapCreate(cxDefaultAllocator, CX_STORE_POINTERS, 16);
     newp->content = newbuffer;
     newp->key = key;
@@ -149,7 +149,7 @@
         PwdIndexEntry *entry = e->value;
         CxList *locations = NULL;
         if(entry->locations) {
-            locations = cxLinkedListCreateSimple(CX_STORE_POINTERS);
+            locations = cxLinkedListCreate(NULL, CX_STORE_POINTERS);
             CxIterator li = cxListIterator(entry->locations);
             cx_foreach(char *, location, li) {
                 cxListAdd(locations, strdup(location));
@@ -206,8 +206,8 @@
     }
       
     char *id = NULL;
-    CxList *locations = cxLinkedListCreateSimple(CX_STORE_POINTERS);
-    cxDefineDestructor(locations, free);
+    CxList *locations = cxLinkedListCreate(NULL, CX_STORE_POINTERS);
+    cxSetDestructor(locations, free);
     
     // get id (required)
     int ret = 0;
@@ -330,7 +330,7 @@
     s->encoffset = PWDS_HEADER_SIZE + indexlen;
     
     // the index starts after the header
-    CxBuffer *index = cxBufferCreate(s->content->space+PWDS_HEADER_SIZE, indexlen, cxDefaultAllocator, 0);
+    CxBuffer *index = cxBufferCreate(cxDefaultAllocator, s->content->space+PWDS_HEADER_SIZE, indexlen, 0);
     index->size = indexlen;
     
     // read index
@@ -352,7 +352,7 @@
     
     // decrypt contet
     size_t encsz = p->content->size - p->encoffset;
-    CxBuffer *enc = cxBufferCreate(p->content->space + p->encoffset, encsz, cxDefaultAllocator, 0);
+    CxBuffer *enc = cxBufferCreate(cxDefaultAllocator, p->content->space + p->encoffset, encsz, 0);
     enc->size = encsz;
     enc->size = p->content->size - p->encoffset;
     CxBuffer *content = aes_decrypt_buffer(enc, p->key);
@@ -398,7 +398,7 @@
 }
 
 void pwdstore_free(PwdStore* p) {
-    cxDefineDestructor(p->ids, pwdstore_free_entry);
+    cxSetDestructor(p->ids, pwdstore_free_entry);
     cxMapFree(p->ids);
     
     cxListFree(p->locations);
@@ -477,8 +477,8 @@
         return 1;
     }
     
-    CxBuffer *index = cxBufferCreate(NULL, 2048, cxDefaultAllocator, CX_BUFFER_FREE_CONTENTS|CX_BUFFER_AUTO_EXTEND);
-    CxBuffer *content = cxBufferCreate(NULL, 2048, cxDefaultAllocator, CX_BUFFER_FREE_CONTENTS|CX_BUFFER_AUTO_EXTEND);
+    CxBuffer *index = cxBufferCreate(cxDefaultAllocator, NULL, 2048, CX_BUFFER_FREE_CONTENTS|CX_BUFFER_AUTO_EXTEND);
+    CxBuffer *content = cxBufferCreate(cxDefaultAllocator, NULL, 2048, CX_BUFFER_FREE_CONTENTS|CX_BUFFER_AUTO_EXTEND);
     
     // create index
     CxIterator i = cxListIterator(p->noloc);
@@ -547,7 +547,7 @@
     
     char *ps_password = NULL;
     if(secrets->unlock_cmd && strlen(secrets->unlock_cmd) > 0) {
-        CxBuffer *cmd_out = cxBufferCreate(NULL, 128, cxDefaultAllocator, CX_BUFFER_FREE_CONTENTS|CX_BUFFER_AUTO_EXTEND);
+        CxBuffer *cmd_out = cxBufferCreate(cxDefaultAllocator, NULL, 128, CX_BUFFER_FREE_CONTENTS|CX_BUFFER_AUTO_EXTEND);
         if(!util_exec_command(secrets->unlock_cmd, cmd_out)) {
             // command successful, get first line from output without newline
             // and use that as password for the secretstore

mercurial