Fix multiple compilation errors and memory leaks.
- Rename malloc_message() because it was causing a compilation error on FreeBSD. - Use correct type as a return from gzdopen(). - Memory allocation, header file includes, etc.
This commit is contained in:
		
							
								
								
									
										68
									
								
								src/config.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										68
									
								
								src/config.h
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,68 @@
 | 
				
			|||||||
 | 
					/* src/config.h.  Generated by configure.  */
 | 
				
			||||||
 | 
					/* src/config.h.in.  Generated from configure.ac by autoheader.  */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Define to 1 if you have the <dirent.h> header file, and it defines `DIR'.
 | 
				
			||||||
 | 
					   */
 | 
				
			||||||
 | 
					#define HAVE_DIRENT_H 1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Define to 1 if you have the `fcntl' function. */
 | 
				
			||||||
 | 
					#define HAVE_FCNTL 1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Define to 1 if you have the `flock' function. */
 | 
				
			||||||
 | 
					#define HAVE_FLOCK 1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Define to 1 if you have the `fts_open' function. */
 | 
				
			||||||
 | 
					#define HAVE_FTS_OPEN 1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Define to 1 if you have the `ftw' function. */
 | 
				
			||||||
 | 
					#define HAVE_FTW 1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Define to 1 if you have the `bz2' library (-lbz2). */
 | 
				
			||||||
 | 
					#define HAVE_LIBBZ2 1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Define to 1 if you have the `dmalloc' library (-ldmalloc). */
 | 
				
			||||||
 | 
					#define HAVE_LIBDMALLOC 1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Define to 1 if you have the `garfield' library (-lgarfield). */
 | 
				
			||||||
 | 
					/* #undef HAVE_LIBGARFIELD */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Define to 1 if you have the `pcre' library (-lpcre). */
 | 
				
			||||||
 | 
					#define HAVE_LIBPCRE 1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Define to 1 if you have the `z' library (-lz). */
 | 
				
			||||||
 | 
					#define HAVE_LIBZ 1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Define to 1 if you have the <ndir.h> header file, and it defines `DIR'. */
 | 
				
			||||||
 | 
					/* #undef HAVE_NDIR_H */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Define to 1 if you have the `regcomp' function. */
 | 
				
			||||||
 | 
					#define HAVE_REGCOMP 1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Define to 1 if you have the `strptime' function. */
 | 
				
			||||||
 | 
					#define HAVE_STRPTIME 1
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Define to 1 if you have the <sys/dir.h> header file, and it defines `DIR'.
 | 
				
			||||||
 | 
					   */
 | 
				
			||||||
 | 
					/* #undef HAVE_SYS_DIR_H */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Define to 1 if you have the <sys/ndir.h> header file, and it defines `DIR'.
 | 
				
			||||||
 | 
					   */
 | 
				
			||||||
 | 
					/* #undef HAVE_SYS_NDIR_H */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Define to the address where bug reports for this package should be sent. */
 | 
				
			||||||
 | 
					#define PACKAGE_BUGREPORT ""
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Define to the full name of this package. */
 | 
				
			||||||
 | 
					#define PACKAGE_NAME ""
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Define to the full name and version of this package. */
 | 
				
			||||||
 | 
					#define PACKAGE_STRING ""
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Define to the one symbol short name of this package. */
 | 
				
			||||||
 | 
					#define PACKAGE_TARNAME ""
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Define to the version of this package. */
 | 
				
			||||||
 | 
					#define PACKAGE_VERSION ""
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Define to 1 if you have the ANSI C header files. */
 | 
				
			||||||
 | 
					#define STDC_HEADERS 1
 | 
				
			||||||
@@ -122,7 +122,7 @@ maildir_read_message (maildir_t *mdp)
 | 
				
			|||||||
  static FILE *fp;
 | 
					  static FILE *fp;
 | 
				
			||||||
  static int s;
 | 
					  static int s;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  message = malloc_message ();
 | 
					  message = allocate_message ();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  for(;;)
 | 
					  for(;;)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -237,7 +237,7 @@ mbox_read_message (mbox_t * mp)
 | 
				
			|||||||
  char buffer[BUFSIZ];
 | 
					  char buffer[BUFSIZ];
 | 
				
			||||||
  message_t *message;
 | 
					  message_t *message;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  message = malloc_message ();
 | 
					  message = allocate_message ();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  s = strlen (mp->postmark_cache);
 | 
					  s = strlen (mp->postmark_cache);
 | 
				
			||||||
  message->headers =
 | 
					  message->headers =
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										2
									
								
								src/mh.c
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								src/mh.c
									
									
									
									
									
								
							@@ -87,7 +87,7 @@ message_t *mh_read_message (DIR *dp)
 | 
				
			|||||||
  char buffer[BUFSIZ], *filename;
 | 
					  char buffer[BUFSIZ], *filename;
 | 
				
			||||||
  FILE *fp;
 | 
					  FILE *fp;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  message = malloc_message ();
 | 
					  message = allocate_message ();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  filename = NULL;
 | 
					  filename = NULL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -139,7 +139,7 @@ char * parse_return_path(char *rpath)
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
/* }}} */
 | 
					/* }}} */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void * malloc_message (void)
 | 
					void * allocate_message (void)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  message_t *message;
 | 
					  message_t *message;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -29,7 +29,7 @@ format_t folder_format (const char *name);
 | 
				
			|||||||
lockmethod_t lock_method (const char *name);
 | 
					lockmethod_t lock_method (const char *name);
 | 
				
			||||||
/* time_t parse_date(char *datestr); */
 | 
					/* time_t parse_date(char *datestr); */
 | 
				
			||||||
char * parse_return_path(char *rpath);
 | 
					char * parse_return_path(char *rpath);
 | 
				
			||||||
void * malloc_message (void);
 | 
					void * allocate_message (void);
 | 
				
			||||||
void postmark_print (message_t *msg);
 | 
					void postmark_print (message_t *msg);
 | 
				
			||||||
void set_default_options (void);
 | 
					void set_default_options (void);
 | 
				
			||||||
void get_runtime_options (int *argc, char **argv, struct option *long_options);
 | 
					void get_runtime_options (int *argc, char **argv, struct option *long_options);
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										2
									
								
								src/re.c
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								src/re.c
									
									
									
									
									
								
							@@ -26,6 +26,7 @@
 | 
				
			|||||||
#endif /* HAVE_LIBPCRE */
 | 
					#endif /* HAVE_LIBPCRE */
 | 
				
			||||||
#include "mboxgrep.h"
 | 
					#include "mboxgrep.h"
 | 
				
			||||||
#include "message.h"
 | 
					#include "message.h"
 | 
				
			||||||
 | 
					#include "wrap.h" /* xcalloc() et cetera */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef HAVE_LIBPCRE
 | 
					#ifdef HAVE_LIBPCRE
 | 
				
			||||||
void
 | 
					void
 | 
				
			||||||
@@ -82,6 +83,7 @@ regex_init (void)
 | 
				
			|||||||
  if (config.extended)
 | 
					  if (config.extended)
 | 
				
			||||||
    flag2 = REG_EXTENDED;
 | 
					    flag2 = REG_EXTENDED;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  config.posix_pattern = (regex_t *) xmalloc (sizeof (regex_t));
 | 
				
			||||||
  errcode = regcomp ((regex_t *) config.posix_pattern, config.regex_s, 
 | 
					  errcode = regcomp ((regex_t *) config.posix_pattern, config.regex_s, 
 | 
				
			||||||
		     (flag1 | flag2 | REG_NEWLINE ));
 | 
							     (flag1 | flag2 | REG_NEWLINE ));
 | 
				
			||||||
  if (0 != errcode)
 | 
					  if (0 != errcode)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -42,6 +42,9 @@
 | 
				
			|||||||
#ifdef HAVE_LIBZ
 | 
					#ifdef HAVE_LIBZ
 | 
				
			||||||
#include <zlib.h>
 | 
					#include <zlib.h>
 | 
				
			||||||
#endif /* HAVE_LIBZ */
 | 
					#endif /* HAVE_LIBZ */
 | 
				
			||||||
 | 
					#ifdef HAVE_LIBBZ2
 | 
				
			||||||
 | 
					#include <bzlib.h>
 | 
				
			||||||
 | 
					#endif /* HAVE_LIBBZ2 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <sys/types.h>
 | 
					#include <sys/types.h>
 | 
				
			||||||
#include <sys/stat.h>
 | 
					#include <sys/stat.h>
 | 
				
			||||||
@@ -108,9 +111,9 @@ FILE *m_fdopen (int fildes, const char *mode)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#ifdef HAVE_LIBZ
 | 
					#ifdef HAVE_LIBZ
 | 
				
			||||||
 | 
					
 | 
				
			||||||
gzFile *m_gzdopen (int fildes, const char *mode)
 | 
					gzFile m_gzdopen (int fildes, const char *mode)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  gzFile *blah;
 | 
					  gzFile blah;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  blah = gzdopen (fildes, mode);
 | 
					  blah = gzdopen (fildes, mode);
 | 
				
			||||||
  if (blah == NULL)
 | 
					  if (blah == NULL)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -56,7 +56,7 @@ int m_open (const char *pathname, int flags, mode_t mode);
 | 
				
			|||||||
FILE *m_fopen (const char *path, const char *mode);
 | 
					FILE *m_fopen (const char *path, const char *mode);
 | 
				
			||||||
FILE *m_fdopen (int fildes, const char *mode);
 | 
					FILE *m_fdopen (int fildes, const char *mode);
 | 
				
			||||||
#ifdef HAVE_LIBZ
 | 
					#ifdef HAVE_LIBZ
 | 
				
			||||||
gzFile *m_gzdopen (int fildes, const char *mode);
 | 
					gzFile m_gzdopen (int fildes, const char *mode);
 | 
				
			||||||
void gzwrite_loop (void *fp, char *str);
 | 
					void gzwrite_loop (void *fp, char *str);
 | 
				
			||||||
#endif /* HAVE_LIBZ */
 | 
					#endif /* HAVE_LIBZ */
 | 
				
			||||||
#ifdef HAVE_LIBBZ2
 | 
					#ifdef HAVE_LIBBZ2
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user