# include "config.h"
#endif
+#include <lib-lib/mem.h>
+
#include "mutt.h"
#include "ascii.h"
#include "handler.h"
* below is to avoid creating a HEADER structure in message_handler().
*/
int
-mutt_copy_hdr (FILE* in, FILE* out, LOFF_T off_start, LOFF_T off_end,
+mutt_copy_hdr (FILE* in, FILE* out, off_t off_start, off_t off_end,
int flags, const char *prefix) {
int from = 0;
int this_is_from;
debug_print (1, ("WEED is %s\n", (flags & CH_WEED) ? "Set" : "Not"));
- headers = mem_calloc (hdr_count, sizeof (char *));
+ headers = p_new(char *, hdr_count);
/* Read all the headers into the array */
while (ftello (in) < off_end) {
mem_realloc (&headers[x], str_len (headers[x]) +
str_len (this_one) + sizeof (char));
strcat (headers[x], this_one); /* __STRCAT_CHECKED__ */
- mem_free (&this_one);
+ p_delete(&this_one);
}
this_one = NULL;
mem_realloc (&headers[x], str_len (headers[x]) +
str_len (this_one) + sizeof (char));
strcat (headers[x], this_one); /* __STRCAT_CHECKED__ */
- mem_free (&this_one);
+ p_delete(&this_one);
}
this_one = NULL;
/* Free in a separate loop to be sure that all headers are freed
* in case of error. */
for (x = 0; x < hdr_count; x++)
- mem_free (&headers[x]);
- mem_free (&headers);
+ p_delete(&headers[x]);
+ p_delete(&headers);
if (error)
return (-1);
/* Mutt stores references in reverse order, thus we create
* a reordered refs list that we can put in the headers */
for (; listp; listp = listp->next, refs = t) {
- t = (LIST *) mem_malloc (sizeof (LIST));
+ t = p_new(LIST, 1);
t->data = listp->data;
t->next = refs;
}
/* clearing refs from memory */
for (t = refs; refs; refs = t->next, t = refs)
- mem_free (&refs);
+ p_delete(&refs);
if (fputc ('\n', out) == EOF)
return (-1);
}
if (flags & CH_UPDATE_LEN && (flags & CH_NOLEN) == 0) {
- fprintf (out, "Content-Length: " OFF_T_FMT "\n", h->content->length);
+ fprintf (out, "Content-Length: %zd\n", h->content->length);
if (h->lines != 0 || h->content->length == 0)
fprintf (out, "Lines: %d\n", h->lines);
}
}
/* Count the number of lines and bytes to be deleted in this body*/
-static int count_delete_lines (FILE * fp, BODY * b, LOFF_T *length,
+static int count_delete_lines (FILE * fp, BODY * b, off_t *length,
size_t datelen)
{
int dellines = 0;
{
char prefix[SHORT_STRING];
STATE s;
- LOFF_T new_offset = -1;
+ off_t new_offset = -1;
int rc = 0;
if (flags & M_CM_PREFIX) {
else if (hdr->attach_del && (chflags & CH_UPDATE_LEN)) {
int new_lines;
- LOFF_T new_length = body->length;
+ off_t new_length = body->length;
char date[SHORT_STRING];
mutt_make_date (date, sizeof (date));
if (mutt_copy_header (fpin, hdr, fpout,
chflags | CH_NOLEN | CH_NONEWLINE, NULL))
return -1;
- fprintf (fpout, "Content-Length: " OFF_T_FMT "\n", new_length);
+ fprintf (fpout, "Content-Length: %zd\n", new_length);
if (new_lines <= 0)
new_lines = 0;
else
#ifdef DEBUG
{
- LOFF_T fail = ((ftello (fpout) - new_offset) - new_length);
+ off_t fail = ((ftello (fpout) - new_offset) - new_length);
if (fail) {
mutt_error ("The length calculation was wrong by %ld bytes", fail);
if (part->deleted) {
fprintf (fpout,
"Content-Type: message/external-body; access-type=x-mutt-deleted;\n"
- "\texpiration=%s; length=" OFF_T_FMT "\n"
+ "\texpiration=%s; length=%zd\n"
"\n", date + 5, part->length);
if (ferror (fpout))
return -1;
mutt_addrlist_to_local (a);
rfc2047_decode_adrlist (a);
- *h = mem_calloc (1, l + 2);
-
- strfcpy (*h, s, l + 1);
+ *h = p_dupstr(s, l + 1);
format_address_header (h, a);
rfc822_free_address (&a);
- mem_free (&s);
+ p_delete(&s);
return 1;
}