RSSC: remove old malloc not needed anymore.
[citadel.git] / citadel / msgbase.c
index e9855ea42b12afdb8f30e484217ef460a9c3645c..825e8970a9ca9f37d4f88b885377c52be2110701 100644 (file)
@@ -116,6 +116,15 @@ char *msgkeys[] = {
        NULL    /* Z */
 };
 
+void CtdlMsgSetCM_Fields(struct CtdlMessage *Msg, const char which, const char *buf, long length)
+{
+       if (Msg->cm_fields[which] != NULL)
+               free (Msg->cm_fields[which]);
+       Msg->cm_fields[which] = malloc(length + 1);
+       memcpy(Msg->cm_fields[which], buf, length);
+       Msg->cm_fields[which][length] = '\0';
+}
+
 /*
  * This function is self explanatory.
  * (What can I say, I'm in a weird mood today...)
@@ -1138,7 +1147,7 @@ void mime_download(char *name, char *filename, char *partnum, char *disp,
                        return;
                }
        
-               rv = fwrite(content, length, 1, CC->download_fp);
+               rv = fwrite(content, length, 1, CCC->download_fp);
                if (rv <= 0) {
                        MSG_syslog(LOG_EMERG, "mime_download(): Couldn't write: %s\n",
                                   strerror(errno));
@@ -1204,6 +1213,7 @@ struct CtdlMessage *CtdlFetchMessage(long msgnum, int with_body)
        MSG_syslog(LOG_DEBUG, "CtdlFetchMessage(%ld, %d)\n", msgnum, with_body);
        dmsgtext = cdb_fetch(CDB_MSGMAIN, &msgnum, sizeof(long));
        if (dmsgtext == NULL) {
+               MSG_syslog(LOG_ERR, "CtdlFetchMessage(%ld, %d) Failed!\n", msgnum, with_body);
                return NULL;
        }
        mptr = dmsgtext->ptr;
@@ -1335,7 +1345,7 @@ struct CtdlMessage * CtdlDuplicateMessage(struct CtdlMessage *OrgMsg)
        if (NewMsg == NULL)
                return NULL;
 
-       memcpy(NewMsg, OrgMsg, sizeof(struct CtdlMessage *));
+       memcpy(NewMsg, OrgMsg, sizeof(struct CtdlMessage));
 
        memset(&NewMsg->cm_fields, 0, sizeof(char*) * 256);
        
@@ -3542,7 +3552,7 @@ long CtdlSubmitMsg(struct CtdlMessage *msg,       /* message to save */
  */
 void quickie_message(const char *from,
                     const char *fromaddr,
-                    char *to,
+                    const char *to,
                     char *room,
                     const char *text, 
                     int format_type,
@@ -3589,7 +3599,7 @@ void quickie_message(const char *from,
 
 void flood_protect_quickie_message(const char *from,
                                   const char *fromaddr,
-                                  char *to,
+                                  const char *to,
                                   char *room,
                                   const char *text, 
                                   int format_type,