From 8b680e72ac5f555f73373a146dd829d099398277 Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Fri, 16 Mar 2012 23:14:49 +1100 Subject: [PATCH] Remove redundant code. --- rzip.c | 4 ++++ stream.c | 63 -------------------------------------------------------- 2 files changed, 4 insertions(+), 63 deletions(-) diff --git a/rzip.c b/rzip.c index 9699b96..3d5d5a4 100644 --- a/rzip.c +++ b/rzip.c @@ -747,6 +747,10 @@ static void init_hash_indexes(struct rzip_state *st) st->hash_index[i] = ((random() << 16) ^ random()); } +#if defined(__APPLE__) || defined(__FreeBSD__) +# define mremap fake_mremap +#endif + static inline void *fake_mremap(void *old_address, size_t old_size, size_t new_size, int flags __UNUSED__) { munmap(old_address, old_size); diff --git a/stream.c b/stream.c index 81f4f61..3325e24 100644 --- a/stream.c +++ b/stream.c @@ -54,23 +54,12 @@ # include #endif - /* LZMA C Wrapper */ #include "lzma/C/LzmaLib.h" #include "util.h" #include "lrzip.h" - -#if defined(__APPLE__) || defined(__FreeBSD__) -# define fmemopen(s, len, modes) fake_fmemopen(control, (s), (len), (modes)) -# define open_memstream(bufloc, sizeloc) fake_open_memstream(control, (bufloc), (sizeloc)) -# define memstream_update_buffer fake_open_memstream_update_buffer -# define mremap fake_mremap -#else -# define memstream_update_buffer(A, B, C) (0) -#endif - #define STREAM_BUFSIZE (1024 * 1024 * 10) static struct compress_thread{ @@ -176,58 +165,6 @@ bool join_pthread(rzip_control *control, pthread_t th, void **thread_return) */ static int lzo_compresses(rzip_control *control, uchar *s_buf, i64 s_len); -static inline FILE *fake_fmemopen(rzip_control *control, void *buf, size_t buflen, char *mode) -{ - FILE *in; - - if (unlikely(strcmp(mode, "r"))) - failure_return(("fake_fmemopen only supports mode \"r\"."), NULL); - in = tmpfile(); - if (unlikely(!in)) - return NULL; - if (unlikely(fwrite(buf, buflen, 1, in) != 1)) { - fclose(in); - return NULL; - } - rewind(in); - - return in; -} - -static inline FILE *fake_open_memstream(rzip_control *control, char **buf, size_t *length) -{ - FILE *out; - - if (unlikely(buf == NULL || length == NULL)) - failure_return(("NULL parameter to fake_open_memstream"), NULL); - out = tmpfile(); - if (unlikely(!out)) - return NULL; - return out; -} - -static inline int fake_open_memstream_update_buffer(FILE *fp, uchar **buf, size_t *length) -{ - long original_pos = ftell(fp); - - if (unlikely(fseek(fp, 0, SEEK_END))) - return -1; - *length = ftell(fp); - rewind(fp); - *buf = (uchar *)malloc(*length); - if (unlikely(!*buf)) - return -1; - if (unlikely(fread(*buf, *length, 1, fp) != 1)) { - free(*buf); - return -1; - } - if (unlikely(fseek(fp, original_pos, SEEK_SET))) { - free(*buf); - return -1; - } - return 0; -} - /* ***** COMPRESSION FUNCTIONS *****