Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
31cbdfa4
Commit
31cbdfa4
authored
Aug 01, 2019
by
Zebediah Figura
Committed by
Alexandre Julliard
Aug 02, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mspatcha: Use the standard max() and min() macros.
Signed-off-by:
Zebediah Figura
<
z.figura12@gmail.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
3f848c3a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
21 deletions
+16
-21
lzxd_dec.c
dlls/mspatcha/lzxd_dec.c
+7
-9
pa19.c
dlls/mspatcha/pa19.c
+9
-12
No files found.
dlls/mspatcha/lzxd_dec.c
View file @
31cbdfa4
...
...
@@ -54,8 +54,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(mspatcha);
#define E8_TRANSFORM_LIMIT_BITS 30
#define E8_TRANSFORM_DEAD_ZONE 10
#define my_min(a, b) ((a) < (b) ? (a) : (b))
struct
LZXD_dec
{
/* use byte pointers instead of uint16 for simplicity on uncompressed
* chunks, and the stream is not 16-bit aligned anyway */
...
...
@@ -120,7 +118,7 @@ static int init_chunk(struct LZXD_dec *dec, size_t index, size_t buf_limit)
dec
->
bit_pos
=
0
;
dec
->
tail_bits
=
0
;
dec
->
uncomp_chunk_end
=
m
y_m
in
(
buf_limit
,
index
+
MAX_CHUNK_UNCOMPRESSED_SIZE
);
dec
->
uncomp_chunk_end
=
min
(
buf_limit
,
index
+
MAX_CHUNK_UNCOMPRESSED_SIZE
);
return
0
;
}
...
...
@@ -407,8 +405,8 @@ static int copy_uncompressed(struct LZXD_dec *dec, BYTE *base, size_t *index_ptr
while
(
dec
->
src
<
dec
->
stream_end
)
{
/* now treat the input as an unaligned byte stream */
size_t
to_copy
=
m
y_m
in
(
end
-
index
,
dec
->
uncomp_chunk_end
-
index
);
to_copy
=
m
y_m
in
(
to_copy
,
(
size_t
)(
dec
->
stream_end
-
dec
->
src
));
size_t
to_copy
=
min
(
end
-
index
,
dec
->
uncomp_chunk_end
-
index
);
to_copy
=
min
(
to_copy
,
(
size_t
)(
dec
->
stream_end
-
dec
->
src
));
memcpy
(
base
+
index
,
dec
->
src
,
to_copy
);
index
+=
to_copy
;
...
...
@@ -522,7 +520,7 @@ static int decode_lzxd_block(struct LZXD_dec *dec, BYTE *base, size_t predef_siz
ret_if_failed
(
make_huffman_codes
(
codes
,
dec
->
len_lengths
,
LEN_CODE_COUNT
));
make_decode_table
(
dec
->
len_table
,
codes
,
dec
->
len_lengths
,
MAX_CODE_LEN
,
LEN_CODE_COUNT
);
block_limit
=
m
y_m
in
(
buf_limit
,
index
+
block_size
);
block_limit
=
min
(
buf_limit
,
index
+
block_size
);
while
(
index
<
block_limit
)
{
...
...
@@ -606,7 +604,7 @@ static int decode_lzxd_block(struct LZXD_dec *dec, BYTE *base, size_t predef_siz
--
length
;
}
end
=
m
y_m
in
(
index
+
length
,
block_limit
);
end
=
min
(
index
+
length
,
block_limit
);
while
(
index
<
end
)
{
base
[
index
]
=
base
[
index
-
dist
];
...
...
@@ -624,12 +622,12 @@ static int decode_lzxd_block(struct LZXD_dec *dec, BYTE *base, size_t predef_siz
static
void
reverse_e8_transform
(
BYTE
*
decode_buf
,
ptrdiff_t
len
,
ptrdiff_t
e8_file_size
)
{
ptrdiff_t
limit
=
m
y_m
in
((
ptrdiff_t
)
1
<<
E8_TRANSFORM_LIMIT_BITS
,
len
);
ptrdiff_t
limit
=
min
((
ptrdiff_t
)
1
<<
E8_TRANSFORM_LIMIT_BITS
,
len
);
ptrdiff_t
i
;
for
(
i
=
0
;
i
<
limit
;
)
{
ptrdiff_t
end
=
m
y_m
in
(
i
+
MAX_CHUNK_UNCOMPRESSED_SIZE
-
E8_TRANSFORM_DEAD_ZONE
,
ptrdiff_t
end
=
min
(
i
+
MAX_CHUNK_UNCOMPRESSED_SIZE
-
E8_TRANSFORM_DEAD_ZONE
,
limit
-
E8_TRANSFORM_DEAD_ZONE
);
ptrdiff_t
next
=
i
+
MAX_CHUNK_UNCOMPRESSED_SIZE
;
...
...
dlls/mspatcha/pa19.c
View file @
31cbdfa4
...
...
@@ -50,9 +50,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(mspatcha);
#define PA19_FILE_MAGIC 0x39314150
#define PATCH_OPTION_EXTRA_FLAGS 0x80000000
#define my_max(a, b) ((a) > (b) ? (a) : (b))
#define my_min(a, b) ((a) < (b) ? (a) : (b))
static
UINT32
compute_zero_crc32
(
UINT32
crc
,
INT_PTR
len
)
{
static
const
BYTE
zero_buffer
[
1024
];
...
...
@@ -173,7 +170,7 @@ static UINT64 read_uvli(struct patch_file_header *ph)
const
BYTE
*
vli
=
ph
->
src
;
UINT64
n
;
ptrdiff_t
i
;
ptrdiff_t
limit
=
m
y_m
in
(
ph
->
end
-
vli
,
9
);
ptrdiff_t
limit
=
min
(
ph
->
end
-
vli
,
9
);
if
(
ph
->
src
>=
ph
->
end
)
{
...
...
@@ -204,7 +201,7 @@ static INT64 read_svli(struct patch_file_header *ph)
const
BYTE
*
vli
=
ph
->
src
;
INT64
n
;
ptrdiff_t
i
;
ptrdiff_t
limit
=
m
y_m
in
(
ph
->
end
-
vli
,
9
);
ptrdiff_t
limit
=
min
(
ph
->
end
-
vli
,
9
);
if
(
ph
->
src
>=
ph
->
end
)
{
...
...
@@ -423,7 +420,7 @@ static int read_header(struct patch_file_header *ph, const BYTE *buf, size_t siz
}
/* skip the crc adjustment field */
ph
->
src
=
m
y_m
in
(
ph
->
src
+
4
,
ph
->
end
);
ph
->
src
=
min
(
ph
->
src
+
4
,
ph
->
end
);
{
UINT32
crc
=
RtlComputeCrc32
(
0
,
buf
,
ph
->
src
-
buf
)
^
0xFFFFFFFF
;
...
...
@@ -464,8 +461,8 @@ static ULONG next_ignored_range(const struct input_file_info *fi, size_t index,
if
(
fi
->
next_i
<
fi
->
ignore_range_count
&&
fi
->
stream_size
!=
0
)
{
start
=
fi
->
ignore_table
[
fi
->
next_i
].
OffsetInOldFile
;
*
end
=
m
y_m
ax
(
start
+
fi
->
ignore_table
[
fi
->
next_i
].
LengthInBytes
,
index
);
start
=
m
y_m
ax
(
start
,
index
);
*
end
=
max
(
start
+
fi
->
ignore_table
[
fi
->
next_i
].
LengthInBytes
,
index
);
start
=
max
(
start
,
index
);
}
return
start
;
}
...
...
@@ -479,8 +476,8 @@ static ULONG next_retained_range_old(const struct input_file_info *fi, size_t in
if
(
fi
->
next_r
<
fi
->
retain_range_count
)
{
start
=
fi
->
retain_table
[
fi
->
next_r
].
OffsetInOldFile
;
*
end
=
m
y_m
ax
(
start
+
fi
->
retain_table
[
fi
->
next_r
].
LengthInBytes
,
index
);
start
=
m
y_m
ax
(
start
,
index
);
*
end
=
max
(
start
+
fi
->
retain_table
[
fi
->
next_r
].
LengthInBytes
,
index
);
start
=
max
(
start
,
index
);
}
return
start
;
}
...
...
@@ -494,8 +491,8 @@ static ULONG next_retained_range_new(const struct input_file_info *fi, size_t in
if
(
fi
->
next_r
<
fi
->
retain_range_count
)
{
start
=
fi
->
retain_table
[
fi
->
next_r
].
OffsetInNewFile
;
*
end
=
m
y_m
ax
(
start
+
fi
->
retain_table
[
fi
->
next_r
].
LengthInBytes
,
index
);
start
=
m
y_m
ax
(
start
,
index
);
*
end
=
max
(
start
+
fi
->
retain_table
[
fi
->
next_r
].
LengthInBytes
,
index
);
start
=
max
(
start
,
index
);
}
return
start
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment