From: Eric Biggers Date: Fri, 13 Dec 2013 19:27:41 +0000 (-0600) Subject: Use STACK_MAX X-Git-Tag: v1.6.0~149 X-Git-Url: https://wimlib.net/git/?p=wimlib;a=commitdiff_plain;h=431652ab74b5aba3fd8ec746d464b0c75eb4e517 Use STACK_MAX --- diff --git a/src/ntfs-3g_capture.c b/src/ntfs-3g_capture.c index 8d5d4c63..6daf0a54 100644 --- a/src/ntfs-3g_capture.c +++ b/src/ntfs-3g_capture.c @@ -91,7 +91,6 @@ read_ntfs_file_prefix(const struct wim_lookup_table_entry *lte, 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) { @@ -108,7 +107,7 @@ read_ntfs_file_prefix(const struct wim_lookup_table_entry *lte, 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); diff --git a/src/win32_capture.c b/src/win32_capture.c index f940179c..6197d9f1 100644 --- a/src/win32_capture.c +++ b/src/win32_capture.c @@ -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; - const size_t stack_max = 32768; 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) { - 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); diff --git a/src/write.c b/src/write.c index c63f0f70..ce301063 100644 --- a/src/write.c +++ b/src/write.c @@ -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; - size_t stack_max = 32768; 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 (chunk_size <= stack_max) { + if (chunk_size <= STACK_MAX) { compressed_chunk = alloca(chunk_size); } else { compressed_chunk = MALLOC(chunk_size); diff --git a/src/xpress-compress.c b/src/xpress-compress.c index ad9dcff7..30a23046 100644 --- a/src/xpress-compress.c +++ b/src/xpress-compress.c @@ -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; - 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 @@ -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 <= 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])); @@ -259,7 +258,7 @@ wimlib_xpress_compress(const void * restrict uncompressed_data, #endif out_free: - if (uncompressed_len > stack_max) { + if (uncompressed_len > STACK_MAX) { FREE(matches); FREE(udata); FREE(prev_tab);