diff --git a/ChangeLog.md b/ChangeLog.md index f48f5977..44b7f157 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -11,6 +11,8 @@ fixes, check out the ## [3.0.0] - 2024-11-28 ### Added + - Colorization of output in stream targets via ANSI color codes, along with + supporting functions `stumpless_set_severity_color`. - Memory allocation function accessors: * `stumpless_get_free` * `stumpless_get_malloc` diff --git a/include/stumpless/element.h b/include/stumpless/element.h index f6e23918..2f56e054 100644 --- a/include/stumpless/element.h +++ b/include/stumpless/element.h @@ -240,34 +240,6 @@ STUMPLESS_PUBLIC_FUNCTION struct stumpless_element * stumpless_copy_element( const struct stumpless_element *element ); -/** - * An alias for stumpless_destroy_element_and_contents. - * - * **Thread Safety: MT-Unsafe** - * This function is not thread safe as it destroys resources that other threads - * would use if they tried to reference this struct. - * - * **Async Signal Safety: AS-Unsafe lock heap** - * This function is not safe to call from signal handlers due to the destruction - * of a lock that may be in use as well as the use of the memory deallocation - * function to release memory. - * - * **Async Cancel Safety: AC-Unsafe lock heap** - * This function is not safe to call from threads that may be asynchronously - * cancelled, as the cleanup of the lock may not be completed, and the memory - * deallocation function may not be AC-Safe itself. - * - * @deprecated This function has been deprecated in favor of the more - * descriptive and deliberate stumpless_destroy_element_and_contents and - * stumpless_destroy_element_only functions in order to avoid unintentional - * memory leaks and use-after-free mistakes. - * - * @param element The element to destroy. - */ -STUMPLESS_PUBLIC_FUNCTION -void -stumpless_destroy_element( const struct stumpless_element *element ); - /** * Destroys an element as well as all params that it contains, freeing any * allocated memory. diff --git a/include/stumpless/entry.h b/include/stumpless/entry.h index bcea3bbf..705c4151 100644 --- a/include/stumpless/entry.h +++ b/include/stumpless/entry.h @@ -265,34 +265,6 @@ STUMPLESS_PUBLIC_FUNCTION struct stumpless_entry * stumpless_copy_entry( const struct stumpless_entry *entry ); -/** - * An alias for stumpless_destroy_entry_and_contents. - * - * **Thread Safety: MT-Unsafe** - * This function is not thread safe as it destroys resources that other threads - * would use if they tried to reference this struct. - * - * **Async Signal Safety: AS-Unsafe lock heap** - * This function is not safe to call from signal handlers due to the destruction - * of a lock that may be in use as well as the use of the memory deallocation - * function to release memory. - * - * **Async Cancel Safety: AC-Unsafe lock heap** - * This function is not safe to call from threads that may be asynchronously - * cancelled, as the cleanup of the lock may not be completed, and the memory - * deallocation function may not be AC-Safe itself. - * - * @deprecated This function has been deprecated in favor of the more - * descriptive and deliberate stumpless_destroy_entry_and_contents and - * stumpless_destroy_entry_only functions in order to avoid unintentional - * memory leaks and use-after-free mistakes. - * - * @param entry The entry to destroy. - */ -STUMPLESS_PUBLIC_FUNCTION -void -stumpless_destroy_entry( const struct stumpless_entry *entry ); - /** * Destroys an entry as well as all elements and params that it contains, * freeing any allocated memory. diff --git a/src/element.c b/src/element.c index 37f41a60..1ee04c32 100644 --- a/src/element.c +++ b/src/element.c @@ -25,7 +25,6 @@ #include "private/config/wrapper/locale.h" #include "private/config/wrapper/journald.h" #include "private/config/wrapper/thread_safety.h" -#include "private/deprecate.h" #include "private/element.h" #include "private/error.h" #include "private/memory.h" @@ -114,18 +113,6 @@ stumpless_copy_element( const struct stumpless_element *element ) { return NULL; } -void -stumpless_destroy_element( const struct stumpless_element *element ) { - warn_of_deprecation( "stumpless_destroy_element has been deprecated in favor " - "of the more descriptive and deliberate " - "stumpless_destroy_element_and_contents and " - "stumpless_destroy_element_only functions in order to " - "avoid unintentional memory leaks and use-after-free " - "mistakes" ); - - stumpless_destroy_element_and_contents( element ); -} - void stumpless_destroy_element_and_contents( const struct stumpless_element *e ) { size_t i; diff --git a/src/entry.c b/src/entry.c index 2ec6c947..1194c5c1 100644 --- a/src/entry.c +++ b/src/entry.c @@ -34,7 +34,6 @@ #include "private/config/wrapper/thread_safety.h" #include "private/config/wrapper/wel.h" #include "private/config/wrapper/wstring.h" -#include "private/deprecate.h" #include "private/element.h" #include "private/entry.h" #include "private/error.h" @@ -159,7 +158,8 @@ stumpless_copy_entry( const struct stumpless_entry *entry ) { copy->elements = alloc_array( entry->element_count, sizeof( element_copy ) ); if( !copy->elements ) { - goto fail_elements; + unchecked_destroy_entry( copy ); + goto cleanup_and_fail; } for( i = 0; i < entry->element_count; i++ ){ @@ -188,18 +188,6 @@ stumpless_copy_entry( const struct stumpless_entry *entry ) { return NULL; } -void -stumpless_destroy_entry( const struct stumpless_entry *entry ) { - warn_of_deprecation( "stumpless_destroy_entry has been deprecated in favor " - "of the more descriptive and deliberate " - "stumpless_destroy_entry_and_contents and " - "stumpless_destroy_entry_only functions in order to " - "avoid unintentional memory leaks and use-after-free " - "mistakes" ); - - stumpless_destroy_entry_and_contents( entry ); -} - void stumpless_destroy_entry_and_contents( const struct stumpless_entry *entry ) { size_t i; diff --git a/src/windows/stumpless.def b/src/windows/stumpless.def index 80e31b8b..53d876f8 100644 --- a/src/windows/stumpless.def +++ b/src/windows/stumpless.def @@ -8,8 +8,14 @@ EXPORTS stumpless_add_entry @3 stumpless_add_param @4 stumpless_close_buffer_target @5 - stumpless_destroy_element @6 - stumpless_destroy_entry @7 + +; formerly stumpless_destroy_element, replaced in 3.0.0 + stumpless_set_severity_color @6 + +; formerly stumpless_destroy_entry, replaced in 3.0.0 + stumpless_get_malloc @7 + +; added in v 1.5.0 and earlier stumpless_destroy_param @8 stumpless_get_current_target @9 stumpless_get_error @10 @@ -244,10 +250,9 @@ EXPORTS stumpless_get_chain_length @227 stumpless_new_chain @228 stumpless_set_entry_message_str_w @229 - stumpless_get_prival_string @230 - stumpless_set_severity_color @231 - stumpless_get_malloc @232 - stumpless_get_free @233 - stumpless_get_realloc @234 - stumpless_get_priority_string @235 + +; added in v3.0.0 + stumpless_get_free @231 + stumpless_get_realloc @232 + stumpless_get_priority_string @233 diff --git a/test/function/target/stream.cpp b/test/function/target/stream.cpp index 986cfc64..1bb2ebe2 100644 --- a/test/function/target/stream.cpp +++ b/test/function/target/stream.cpp @@ -269,7 +269,7 @@ namespace { #else save_stderr = dup(save_stderr); #endif - freopen(filename, "a+", stderr); + ASSERT_NOT_NULL( freopen( filename, "a+", stderr )); stumpless_add_log_str(target, i, stumpless_get_severity_string((enum stumpless_severity)i)); @@ -342,7 +342,7 @@ namespace { #else save_stdout = dup(save_stdout); #endif - freopen(filename, "a+", stdout); + ASSERT_NOT_NULL( freopen( filename, "a+", stdout )); stumpless_add_log_str(target, i, stumpless_get_severity_string((enum stumpless_severity)i)); diff --git a/tools/check_headers/stumpless.yml b/tools/check_headers/stumpless.yml index b048d9db..6f54ec71 100644 --- a/tools/check_headers/stumpless.yml +++ b/tools/check_headers/stumpless.yml @@ -1,9 +1,7 @@ # options "header-alternates": "stumpless/.*\\.h": "stumpless.h" -"deprecated-terms": - - "stumpless_destroy_element" - - "stumpless_destroy_entry" +"deprecated-terms": [] # terms "accept_tcp_connection": "test/helper/server.hpp" diff --git a/tools/cmake/test.cmake b/tools/cmake/test.cmake index 7d0367e3..df63afe4 100644 --- a/tools/cmake/test.cmake +++ b/tools/cmake/test.cmake @@ -35,6 +35,12 @@ function(private_add_function_test) ${FUNCTION_TEST_ARG_LIBRARIES} ) + if("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU") + target_link_libraries(function-test-${FUNCTION_TEST_ARG_NAME} + stdc++fs + ) + endif() + target_include_directories(function-test-${FUNCTION_TEST_ARG_NAME} PRIVATE ${PROJECT_SOURCE_DIR}/include @@ -301,6 +307,12 @@ set_target_properties(test_helper_fixture add_dependencies(test_helper_fixture libgtest) +if("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU") + target_link_libraries(test_helper_fixture + stdc++fs + ) +endif() + target_include_directories(test_helper_fixture PRIVATE ${PROJECT_SOURCE_DIR}/include