X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=blobdiff_plain;f=compress.c;h=01be9d3d6e5b2c43dec930182537bbdccde9122a;hp=e179b7d7b893042ae2d2ce60da252a541e711cee;hb=261efe59606236c666af016344aeecf0b021307d;hpb=ba5e3af4ea19e1d20c80941c077039871ec84258 diff --git a/compress.c b/compress.c index e179b7d..01be9d3 100644 --- a/compress.c +++ b/compress.c @@ -7,6 +7,11 @@ * please see the file GPL in the top level source directory. */ +#include +#include +#include +#include + #include "mutt.h" #ifdef USE_COMPRESSED @@ -15,9 +20,6 @@ #include "mbox.h" #include "mutt_curses.h" -#include "lib/mem.h" -#include "lib/intl.h" -#include "lib/str.h" #include "lib/debug.h" #include @@ -113,7 +115,7 @@ static COMPRESS_INFO *set_compress_info (CONTEXT * ctx) COMPRESS_INFO *ci; /* Now lets uncompress this thing */ - ci = mem_malloc (sizeof (COMPRESS_INFO)); + ci = p_new(COMPRESS_INFO, 1); ctx->compressinfo = (void *) ci; ci->append = find_compress_hook (M_APPENDHOOK, ctx->path); ci->open = find_compress_hook (M_OPENHOOK, ctx->path); @@ -130,8 +132,7 @@ static void set_path (CONTEXT * ctx) /* Uncompress to /tmp */ mutt_mktemp (tmppath); - ctx->path = mem_malloc (str_len (tmppath) + 1); - strcpy (ctx->path, tmppath); + ctx->path = p_dupstr(tmppath, m_strlen(tmppath)); } static int get_size (const char *path) @@ -189,7 +190,7 @@ static char *get_compression_cmd (const char *cmd, const CONTEXT * ctx) mutt_FormatString (expanded, sizeof (expanded), cmd, compresshook_format_str, (unsigned long) ctx, 0); - return str_dup (expanded); + return m_strdup(expanded); } int mutt_check_mailbox_compressed (CONTEXT * ctx) @@ -197,8 +198,8 @@ int mutt_check_mailbox_compressed (CONTEXT * ctx) COMPRESS_INFO *ci = (COMPRESS_INFO *) ctx->compressinfo; if (ci->size != get_size (ctx->realpath)) { - mem_free (&ctx->compressinfo); - mem_free (&ctx->realpath); + p_delete(&ctx->compressinfo); + p_delete(&ctx->realpath); mutt_error _("Mailbox was corrupted!"); return (-1); @@ -216,7 +217,7 @@ int mutt_open_read_compressed (CONTEXT * ctx) if (!ci->open) { ctx->magic = 0; - mem_free (ctx->compressinfo); + p_delete(&ctx->compressinfo); return (-1); } if (!ci->close || access (ctx->path, W_OK) != 0) @@ -235,7 +236,7 @@ int mutt_open_read_compressed (CONTEXT * ctx) if ((fp = fopen (ctx->realpath, "r")) == NULL) { mutt_perror (ctx->realpath); - mem_free (&cmd); + p_delete(&cmd); return (-1); } mutt_block_signals (); @@ -244,7 +245,7 @@ int mutt_open_read_compressed (CONTEXT * ctx) mutt_unblock_signals (); mutt_error _("Unable to lock mailbox!"); - mem_free (&cmd); + p_delete(&cmd); return (-1); } @@ -260,11 +261,11 @@ int mutt_open_read_compressed (CONTEXT * ctx) if (rc) { mutt_any_key_to_continue (NULL); ctx->magic = 0; - mem_free (ctx->compressinfo); + p_delete(&ctx->compressinfo); mutt_error (_("Error executing: %s : unable to open the mailbox!\n"), cmd); } - mem_free (&cmd); + p_delete(&cmd); if (rc) return (-1); @@ -278,7 +279,7 @@ int mutt_open_read_compressed (CONTEXT * ctx) void restore_path (CONTEXT * ctx) { - mem_free (&ctx->path); + p_delete(&ctx->path); ctx->path = ctx->realpath; } @@ -299,7 +300,7 @@ int mutt_open_append_compressed (CONTEXT * ctx) return (mutt_open_read_compressed (ctx)); ctx->magic = 0; - mem_free (&ctx->compressinfo); + p_delete(&ctx->compressinfo); return (-1); } @@ -332,7 +333,7 @@ void mutt_fast_close_compressed (CONTEXT * ctx) remove_file (ctx); restore_path (ctx); - mem_free (&ctx->compressinfo); + p_delete(&ctx->compressinfo); } } @@ -353,7 +354,7 @@ int mutt_sync_compressed (CONTEXT * ctx) if ((fp = fopen (ctx->realpath, "a")) == NULL) { mutt_perror (ctx->realpath); - mem_free (&cmd); + p_delete(&cmd); return (-1); } mutt_block_signals (); @@ -364,7 +365,7 @@ int mutt_sync_compressed (CONTEXT * ctx) store_size (ctx); - mem_free (&cmd); + p_delete(&cmd); return (-1); } @@ -386,7 +387,7 @@ int mutt_sync_compressed (CONTEXT * ctx) mutt_unblock_signals (); fclose (fp); - mem_free (&cmd); + p_delete(&cmd); store_size (ctx); @@ -428,7 +429,7 @@ int mutt_slow_close_compressed (CONTEXT * ctx) if ((fp = fopen (ctx->realpath, "a")) == NULL) { mutt_perror (ctx->realpath); - mem_free (&cmd); + p_delete(&cmd); return (-1); } mutt_block_signals (); @@ -437,7 +438,7 @@ int mutt_slow_close_compressed (CONTEXT * ctx) mutt_unblock_signals (); mutt_error _("Unable to lock mailbox!"); - mem_free (&cmd); + p_delete(&cmd); return (-1); } @@ -458,7 +459,7 @@ int mutt_slow_close_compressed (CONTEXT * ctx) mutt_error (_ (" %s: Error compressing mailbox! Uncompressed one kept!\n"), ctx->path); - mem_free (&cmd); + p_delete(&cmd); mbox_unlock_compressed (ctx, fp); mutt_unblock_signals (); fclose (fp); @@ -470,14 +471,14 @@ int mutt_slow_close_compressed (CONTEXT * ctx) fclose (fp); remove_file (ctx); restore_path (ctx); - mem_free (&cmd); - mem_free (&ctx->compressinfo); + p_delete(&cmd); + p_delete(&ctx->compressinfo); return (0); } mx_t* compress_reg_mx (void) { - mx_t* fmt = mem_calloc (1, sizeof (mx_t)); + mx_t* fmt = p_new(mx_t, 1); fmt->type = M_COMPRESSED; fmt->local = 1; fmt->mx_is_magic = mbox_is_magic;