Use STACK_MAX
authorEric Biggers <ebiggers3@gmail.com>
Fri, 13 Dec 2013 19:27:41 +0000 (13:27 -0600)
committerEric Biggers <ebiggers3@gmail.com>
Fri, 13 Dec 2013 19:27:41 +0000 (13:27 -0600)
src/ntfs-3g_capture.c
src/win32_capture.c
src/write.c
src/xpress-compress.c

index 8d5d4c6..6daf0a5 100644 (file)
@@ -91,7 +91,6 @@ read_ntfs_file_prefix(const struct wim_lookup_table_entry *lte,
        void *out_buf;
        bool out_buf_malloced;
        int ret;
        void *out_buf;
        bool out_buf_malloced;
        int ret;
-       size_t stack_max = 32768;
 
        ni = ntfs_pathname_to_inode(vol, NULL, loc->path);
        if (!ni) {
 
        ni = ntfs_pathname_to_inode(vol, NULL, loc->path);
        if (!ni) {
@@ -108,7 +107,7 @@ read_ntfs_file_prefix(const struct wim_lookup_table_entry *lte,
 
        out_buf_malloced = false;
        if (cb) {
 
        out_buf_malloced = false;
        if (cb) {
-               if (in_chunk_size <= stack_max) {
+               if (in_chunk_size <= STACK_MAX) {
                        out_buf = alloca(in_chunk_size);
                } else {
                        out_buf = MALLOC(in_chunk_size);
                        out_buf = alloca(in_chunk_size);
                } else {
                        out_buf = MALLOC(in_chunk_size);
index f940179..6197d9f 100644 (file)
@@ -66,7 +66,6 @@ read_win32_file_prefix(const struct wim_lookup_table_entry *lte,
        void *out_buf;
        bool out_buf_malloced;
        u64 bytes_remaining;
        void *out_buf;
        bool out_buf_malloced;
        u64 bytes_remaining;
-       const size_t stack_max = 32768;
 
        HANDLE hFile = win32_open_existing_file(lte->file_on_disk,
                                                FILE_READ_DATA);
 
        HANDLE hFile = win32_open_existing_file(lte->file_on_disk,
                                                FILE_READ_DATA);
@@ -78,7 +77,7 @@ read_win32_file_prefix(const struct wim_lookup_table_entry *lte,
 
        out_buf_malloced = false;
        if (cb) {
 
        out_buf_malloced = false;
        if (cb) {
-               if (in_chunk_size <= stack_max) {
+               if (in_chunk_size <= STACK_MAX) {
                        out_buf = alloca(in_chunk_size);
                } else {
                        out_buf = MALLOC(in_chunk_size);
                        out_buf = alloca(in_chunk_size);
                } else {
                        out_buf = MALLOC(in_chunk_size);
index c63f0f7..ce30106 100644 (file)
@@ -315,7 +315,6 @@ write_resource_cb(const void *chunk, size_t chunk_size, void *_ctx)
        void *compressed_chunk = NULL;
        unsigned compressed_size;
        bool compressed_chunk_malloced = false;
        void *compressed_chunk = NULL;
        unsigned compressed_size;
        bool compressed_chunk_malloced = false;
-       size_t stack_max = 32768;
 
        if (ctx->doing_sha)
                sha1_update(&ctx->sha_ctx, chunk, chunk_size);
 
        if (ctx->doing_sha)
                sha1_update(&ctx->sha_ctx, chunk, chunk_size);
@@ -325,7 +324,7 @@ write_resource_cb(const void *chunk, size_t chunk_size, void *_ctx)
        if (ctx->out_ctype != WIMLIB_COMPRESSION_TYPE_NONE) {
 
                /* Compress the chunk.  */
        if (ctx->out_ctype != WIMLIB_COMPRESSION_TYPE_NONE) {
 
                /* Compress the chunk.  */
-               if (chunk_size <= stack_max) {
+               if (chunk_size <= STACK_MAX) {
                        compressed_chunk = alloca(chunk_size);
                } else {
                        compressed_chunk = MALLOC(chunk_size);
                        compressed_chunk = alloca(chunk_size);
                } else {
                        compressed_chunk = MALLOC(chunk_size);
index ad9dcff..30a2304 100644 (file)
@@ -164,7 +164,6 @@ wimlib_xpress_compress(const void * restrict uncompressed_data,
        input_idx_t num_matches;
        input_idx_t compressed_len;
        input_idx_t i;
        input_idx_t num_matches;
        input_idx_t compressed_len;
        input_idx_t i;
-       const size_t stack_max = 65536;
 
        /* XPRESS requires 256 bytes of overhead for the Huffman code, so it's
         * impossible to compress 256 bytes or less of data to less than the
 
        /* XPRESS requires 256 bytes of overhead for the Huffman code, so it's
         * impossible to compress 256 bytes or less of data to less than the
@@ -178,7 +177,7 @@ wimlib_xpress_compress(const void * restrict uncompressed_data,
        if (uncompressed_len < XPRESS_NUM_SYMBOLS / 2 + 1 + 4)
                return 0;
 
        if (uncompressed_len < XPRESS_NUM_SYMBOLS / 2 + 1 + 4)
                return 0;
 
-       if (uncompressed_len <= stack_max) {
+       if (uncompressed_len <= STACK_MAX) {
                matches = alloca(uncompressed_len * sizeof(matches[0]));
                udata = alloca(uncompressed_len + 8);
                prev_tab = alloca(uncompressed_len * sizeof(prev_tab[0]));
                matches = alloca(uncompressed_len * sizeof(matches[0]));
                udata = alloca(uncompressed_len + 8);
                prev_tab = alloca(uncompressed_len * sizeof(prev_tab[0]));
@@ -259,7 +258,7 @@ wimlib_xpress_compress(const void * restrict uncompressed_data,
 #endif
 
 out_free:
 #endif
 
 out_free:
-       if (uncompressed_len > stack_max) {
+       if (uncompressed_len > STACK_MAX) {
                FREE(matches);
                FREE(udata);
                FREE(prev_tab);
                FREE(matches);
                FREE(udata);
                FREE(prev_tab);