// Load the message list
num_msgs = CtdlFetchMsgList(qrbuf->QRnumber, &msglist);
- if (num_msgs < 0) {
- return; // No msglists record? No further action.
- }
-
if (num_msgs > 0) {
for (c=0; c<num_msgs; c++) {
if (msglist[c] > cfh->highest_msgnum_found) {
}
}
}
-
free(msglist);
}
}
num_msgs = CtdlFetchMsgList(CC->room.QRnumber, &msglist);
- if (num_msgs >= 0) {
+ if (num_msgs > 0) {
for (i = 0; i < num_msgs; ++i) {
if (msglist[i] == msgnum) {
free(msglist);
if (!strcasecmp(qrbuf->QRname, SYSCONFIGROOM)) return;
// Ok, we got this far ... now let's see what's in the room.
- TRACE;
num_msgs = CtdlFetchMsgList(qrbuf->QRnumber, &msglist);
- TRACE;
// Nothing to do if there aren't any messages
if (num_msgs <= 0) {
// Retrieve a list of all messages (message numbers) in the specified room.
// Returns the number of messages in the room, allocates a pointer to the array and stuffs it in the supplied location.
// Caller must free that memory.
-// Returns (-1) if error.
+// If no messages in room, returns 0 and msgs is set to NULL.
int CtdlFetchMsgList(long roomnum, long **msgs) {
int num_msgs = 0;
struct cdbdata *cdbfr;
if (cdbfr == NULL) {
syslog(LOG_ERR, "room_ops: no msglist for room %ld", roomnum);
*msgs = NULL;
- return (-1);
+ return (0);
}
- *msgs = malloc(cdbfr->len);
- memcpy(*msgs, cdbfr->ptr, cdbfr->len);
num_msgs = cdbfr->len / sizeof(long);
+ if (num_msgs > 0) {
+ *msgs = malloc(cdbfr->len);
+ memcpy(*msgs, cdbfr->ptr, cdbfr->len);
+ }
+ else {
+ *msgs = NULL;
+ }
cdb_free(cdbfr);
// BEGIN diagnostic section remove this
syslog(LOG_DEBUG, "\033[7mCtdlFetchMsgList(%ld) %d messages\033[0m", roomnum, num_msgs);