Commit Graph

491 Commits

Author SHA1 Message Date
Martin Storsjö
208f033bcd Use WelsStrcat instead of the STRCAT macro 2014-01-28 12:43:22 +02:00
Martin Storsjö
fa93c88fa2 Implement WelsStrcat based on WelsStrncpy
This is a more convenient behaviour (truncating on overflow and
always null terminating the buffer) compared to the MSVC
safe strcat_s which aborts the process if the string doesn't fit
into the target buffer.

Also mark the source buffer as const in the function prototype.
2014-01-28 12:27:22 +02:00
Martin Storsjö
9840f11784 Remove the now unused count parameter to WelsStrncpy
Also remove manual null termination as WelsStrncpy now always
takes care of it.
2014-01-28 12:13:11 +02:00
Martin Storsjö
a16ccc0b4d Fix the implementations of WelsStrncpy
Make the MSVC "safe" version truncate instead of aborting the
process if the buffer is too small.

Update all the other functions to use the right parameter
(iSizeInBytes, not iCount) as 'n' parameter to strncpy.
(By passing iCount as parameter to the normal strncpy functions,
it meant that the resulting buffer actually never was null
terminated.)

Additionally make sure that the other implementations of WelsStrncpy
always null terminate the resulting buffer, just as the MSVC safe
version does when passed the _TRUNCATE parameter.
2014-01-28 12:08:35 +02:00
Martin Storsjö
74e7c9b6d8 Remove the now unused STRNCPY macro 2014-01-28 12:06:07 +02:00
Martin Storsjö
215eb56453 Use WelsStrncpy instead of STRNCPY 2014-01-28 12:05:28 +02:00
Martin Storsjö
7791a6d28d Use WelsSnprintf instead of a combination of strlen and STRNCAT
This simplifies the code and makes the buffer size checks
more consistent. Additionally, the previous version wrote
the extra space character without checking if it actually fit
into the buffer.
2014-01-28 12:00:04 +02:00
Martin Storsjö
0318922654 Check the right pointer for being non-null in WelsLogDefault
In case the log level was invalid, GetLogTag returns null.
Checking pCtx doesn't make sense since nothing within the
if block uses pCtx.
2014-01-28 12:00:04 +02:00
Martin Storsjö
9b59153263 Remove the STRNLEN/WelsStrnlen compatibility functions
These were essentially useless - if strlen() ever was used as
fallback, it either indicated that those ports of the library
were insecure, or that strnlen never was required at all.
In this case it turned out to be the latter (at least after
the preceding cleanups) - all uses of it were with known null
terminated strings.
2014-01-28 12:00:04 +02:00
Martin Storsjö
92fa4eb400 Use strlen instead of WelsStrnlen/STRNLEN for known null terminated strings
strlen is not dangerous if the string is known to be null
terminated (and MSVC does not warn about its use either).

For the cases in the decoder welsCodecTrace.cpp, the string
passed to all WriteString instances is produced by WelsVsnprintf
which always null terminates the buffer nowadays.

Additionally, as the string was passed to OutputDebugStringA
without any length specifier before, it was already assumed to
be null terminated.

The file name parameter passed to DumpDependencyRec and
DumpRecFrame in encoder.cpp is always null terminated,
which was already assumed as it is passed to WelsFopen as is.

As for the encoder utils.cpp, the strings returned by GetLogPath
are string constants that are null terminated.
2014-01-28 11:40:54 +02:00
Martin Storsjö
082a986990 Use strlen() instead of WelsStrnlen/STRNLEN for string constants
A string constant is guaranteed to be null terminated, and thus
doesn't need to use a version of strlen with a fixed buffer size
limit.
2014-01-28 11:38:26 +02:00
Martin Storsjö
da7d3d9bad Remove an unused and unnecessary string length calculation
This is unused since 771ff739b.
2014-01-28 11:38:22 +02:00
Ethan Hugg
977768ac88 Merge pull request #222 from mstorsjo/enable-threading
Enable threading when building for most platforms
2014-01-27 14:50:13 -08:00
Ethan Hugg
640c43a3e1 Merge pull request #229 from mstorsjo/make-link-space
Remove spaces from the argument to LINK_LIB
2014-01-27 14:49:28 -08:00
Ethan Hugg
4334812eee Merge pull request #235 from mstorsjo/merge-ls-defines
Merge the ls_defines.h headers into the common sub-library
2014-01-27 14:10:00 -08:00
Ethan Hugg
00a76419b4 Merge pull request #237 from mstorsjo/simplify-make-lib-rules
Simplify the make rules for creating libraries
2014-01-27 14:09:20 -08:00
Ethan Hugg
d9cbe19110 Merge pull request #240 from mstorsjo/simplify-inline-asm
Unify the fallback codepath for getting prefix bits into a macro
2014-01-27 13:07:38 -08:00
Ethan Hugg
5616ddb3a5 Merge pull request #242 from mstorsjo/simplify-debug-file-locations
Simplify debugging code by always writing trace files to the current directory
2014-01-27 13:04:29 -08:00
Ethan Hugg
990a71dce7 Merge pull request #244 from mstorsjo/remove-unused-files
Removed an unused pair of files generated by MSVC project wizards
2014-01-27 13:03:17 -08:00
Ethan Hugg
b00523329f Merge pull request #243 from mstorsjo/use-stdio-wrappers
Consistently use the compat wrappers for file IO
2014-01-27 13:02:51 -08:00
Ethan Hugg
9be2b1a9a8 Merge pull request #241 from mstorsjo/remove-unused-function
Remove an unused function for byte order swapping
2014-01-27 13:02:00 -08:00
Martin Storsjö
d36939580a Removed an unused pair of files generated by MSVC project wizards
These files aren't actually even referenced by the MSVC project
files.
2014-01-27 22:55:33 +02:00
Martin Storsjö
3559f425b4 Consistently use the compat wrappers for file IO
As long as WelsFileHandle* is equal to FILE* this doesn't matter,
but for consistency use the WelsF* functions for all handles
opened by WelsFopen, and use WelsFileHandle* as type for it
instead of FILE*.
2014-01-27 22:49:41 +02:00
Martin Storsjö
98614924e2 Remove the now meaningless field sTracePath 2014-01-27 22:37:11 +02:00
Martin Storsjö
771ff739b6 Simplify debugging code - always write debug trace files to the cur directory
This reduces the amount of platform ifdefs.
2014-01-27 22:36:50 +02:00
Martin Storsjö
60e0255677 Unify the fallback codepath for getting prefix bits into a macro
This avoids having to know the details about when the optimized
codepath is available at the place where it's used.
2014-01-27 22:30:00 +02:00
Martin Storsjö
55717d3fb8 Remove an unused function for byte order swapping 2014-01-27 22:18:23 +02:00
Ethan Hugg
e17e664e1a Merge pull request #239 from mstorsjo/remove-unnecessary-calls
Remove some unnecessary STRNCPY/WelsStrncpy calls and intermediate buffers
2014-01-27 11:50:19 -08:00
Ethan Hugg
e05b607daa Merge pull request #223 from mstorsjo/typedef-cleanup
Clean up typedefs within the libraries
2014-01-27 11:46:44 -08:00
Martin Storsjö
ec20ab58ef Remove some unnecessary STRNCPY/WelsStrncpy calls and intermediate buffers 2014-01-27 20:00:15 +02:00
Ethan Hugg
783adb9afe Merge pull request #238 from mstorsjo/merge-snprintf-strftime-wrappers
Use WelsSnprintf/WelsVsnprintf/WelsGetTimeOfDay/WelsStrftime instead of inconsistent macros
2014-01-27 09:44:51 -08:00
Martin Storsjö
2bcadff204 Use WelsGetTimeOfDay and WelsStrftime instead of LOCALTIME/FTIME/strftime 2014-01-27 19:20:45 +02:00
Martin Storsjö
0439392a79 Fix a typo Millsecond -> Millisecond 2014-01-27 19:20:27 +02:00
Martin Storsjö
3a5ff9b6c8 Use WelsVsnprintf instead of VSPRINTF 2014-01-27 19:18:36 +02:00
Martin Storsjö
f6fe4ddeaa Use WelsSnprintf instead of SNPRINTF 2014-01-27 19:18:36 +02:00
Ethan Hugg
6fea084a42 Merge pull request #234 from mstorsjo/merge-measure-time
Move the measure_time.h header to the common library
2014-01-27 08:57:16 -08:00
Ethan Hugg
2a55578a98 Merge pull request #208 from mstorsjo/remove-unused-mk-field
Remove an unnecessary field from generated makefiles
2014-01-27 08:55:23 -08:00
Ethan Hugg
d5affbaa3c Merge pull request #232 from mstorsjo/merge-fopen-wrappers
Remove the FOPEN macro, use WelsFopen instead
2014-01-27 08:54:20 -08:00
Ethan Hugg
5a8f5f9ad1 Merge pull request #233 from mstorsjo/snprintf-fixes
Make the *snprintf (and similar) functions always null terminate the buffer properly on all platforms
2014-01-27 08:52:37 -08:00
Ethan Hugg
dacd6735fb Merge pull request #230 from mstorsjo/remove-legacy-make
Remove the legacy makefile based build system
2014-01-27 07:59:03 -08:00
Ethan Hugg
fbf7836b8d Merge pull request #236 from mstorsjo/msvc-proj-moved-headers
Update the MSVC project files for earlier moved/removed files
2014-01-27 07:56:25 -08:00
Ethan Hugg
f3afcd51ff Merge pull request #231 from mstorsjo/fix-msvc-build
Readd a removed include
2014-01-27 07:54:29 -08:00
Martin Storsjö
ea8a00278f Simplify the make rules for creating libraries 2014-01-27 14:45:18 +02:00
Martin Storsjö
ea333863ee Update the MSVC project files for earlier moved/removed files 2014-01-27 14:23:22 +02:00
Martin Storsjö
a44808e276 Merge the ls_defines.h headers into the common sub-library 2014-01-27 14:14:41 +02:00
Martin Storsjö
11bdd8adad Move the measure_time.h header to the common library
Both encoder and decoder versions were functionally equivalent,
but I picked the decoder version (but added the static inline
keywords to it) since the encoder one was quite messy with a lot
of commented out code.
2014-01-27 12:58:23 +02:00
Martin Storsjö
c7b74b2b12 Make sure the buffer is null terminated after strftime
If the buffer is too small, there's no guarantee that it is
null terminated. The docs (on both unix and MSVC) say explicitly
that the function returns 0 and the buffer contents are
indeterminate in this case.
2014-01-27 12:07:00 +02:00
Martin Storsjö
7884e77b2d Make sure the buffer always is null terminated in the *snprintf calls for old MSVC
These functions leave the buffer unterminated in case it was too
small.
2014-01-27 12:06:24 +02:00
Martin Storsjö
4a8f54d767 Use vsnprintf in the old MSVC version of WelsSnprintf as well 2014-01-27 12:06:08 +02:00
Martin Storsjö
0ce42ffb89 Rename WelsVsprintf to WelsVsnprintf, to indicate that it actually checks the length 2014-01-27 12:05:53 +02:00