Prepared for upcoming change to cdb_next_item() API.
authorArt Cancro <ajc@citadel.org>
Thu, 10 Aug 2023 14:49:50 +0000 (05:49 -0900)
committerArt Cancro <ajc@citadel.org>
Thu, 10 Aug 2023 14:49:50 +0000 (05:49 -0900)
cdb_next_item() is always preceded by a call to cdb_rewind() before the
iteration loop.  We're going to remove the cursor from thread-specific
data, and replace it with a void pointer that the caller is responsible
for passing back.  This will make the backend drivers easier to build.

citadel/server/room_ops.c
citadel/server/user_ops.c

index 1566e74b0a85261426a9bd1994816048a0beca8b..7fefdbbf3d4b51b8ceb888823c4327635ce1700d 100644 (file)
@@ -528,7 +528,6 @@ void CtdlForEachRoom(ForEachRoomCallBack callback_func, void *in_data) {
        struct cdbdata *cdbqr;
 
        cdb_rewind(CDB_ROOMS);
-
        while (cdbqr = cdb_next_item(CDB_ROOMS), cdbqr != NULL) {
                memset(&qrbuf, 0, sizeof(struct ctdlroom));
                memcpy(&qrbuf, cdbqr->ptr, ((cdbqr->len > sizeof(struct ctdlroom)) ?  sizeof(struct ctdlroom) : cdbqr->len) );
index 31bd579d3ab15a884a698142c35c9272a5f550f8..76897347cd11f10674f7e506dba70d17dfca44ba 100644 (file)
@@ -1043,10 +1043,8 @@ void ForEachUser(void (*CallBack) (char *, void *out_data), void *in_data) {
                return;
        }
 
-
-       cdb_rewind(CDB_USERS);
-
        // Phase 1 : build an array of all our user account names
+       cdb_rewind(CDB_USERS);
        while (cdbus = cdb_next_item(CDB_USERS), cdbus != NULL) {
                usptr = (struct ctdluser *) cdbus->ptr;
                if (strlen(usptr->fullname) > 0) {