From 68c4560701cca29837dfa5a57a730a56be0199fb Mon Sep 17 00:00:00 2001 From: Stella Lau Date: Thu, 13 Jul 2017 10:38:19 -0700 Subject: [PATCH] [ldm] Add TODO and comment for segfaulting in compress function --- contrib/long_distance_matching/ldm.c | 7 +++++-- contrib/long_distance_matching/main-ldm.c | 10 ++++++---- contrib/long_distance_matching/util.c | 5 ----- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/contrib/long_distance_matching/ldm.c b/contrib/long_distance_matching/ldm.c index e64d2865..7a545073 100644 --- a/contrib/long_distance_matching/ldm.c +++ b/contrib/long_distance_matching/ldm.c @@ -28,7 +28,7 @@ #define RUN_MASK ((1U< #include #include @@ -12,12 +10,17 @@ #include #include "ldm.h" +#include "zstd.h" #define DEBUG //#define TEST /* Compress file given by fname and output to oname. * Returns 0 if successful, error code otherwise. + * + * TODO: This currently seg faults if the compressed size is > the decompress + * size due to the mmapping and output file size allocated to be the input size. + * The compress function should check before writing or buffer writes. */ static int compress(const char *fname, const char *oname) { int fdin, fdout; @@ -78,10 +81,9 @@ static int compress(const char *fname, const char *oname) { dst + LDM_HEADER_SIZE, statbuf.st_size); #endif */ - compressSize = LDM_HEADER_SIZE + LDM_compress(src, statbuf.st_size, - dst + LDM_HEADER_SIZE, statbuf.st_size); + dst + LDM_HEADER_SIZE, maxCompressSize); // Write compress and decompress size to header // TODO: should depend on LDM_DECOMPRESS_SIZE write32 diff --git a/contrib/long_distance_matching/util.c b/contrib/long_distance_matching/util.c index 62749215..47ac8a12 100644 --- a/contrib/long_distance_matching/util.c +++ b/contrib/long_distance_matching/util.c @@ -53,11 +53,6 @@ U32 LDM_read32(const void *ptr) { return *(const U32 *)ptr; } -//TODO: endianness? -void LDM_write64(void *memPtr, U64 value) { - memcpy(memPtr, &value, sizeof(value)); -} - U64 LDM_read64(const void *ptr) { return *(const U64 *)ptr; }