Skip to content

Commit

Permalink
remove deprecations
Browse files Browse the repository at this point in the history
Remove deprecated functions stumpless_destroy_element
and stumpless_destroy_entry.
  • Loading branch information
goatshriek authored Nov 28, 2024
1 parent f75f182 commit e292883
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 96 deletions.
2 changes: 2 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
28 changes: 0 additions & 28 deletions include/stumpless/element.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
28 changes: 0 additions & 28 deletions include/stumpless/entry.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
13 changes: 0 additions & 13 deletions src/element.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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;
Expand Down
16 changes: 2 additions & 14 deletions src/entry.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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++ ){
Expand Down Expand Up @@ -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;
Expand Down
21 changes: 13 additions & 8 deletions src/windows/stumpless.def
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
4 changes: 2 additions & 2 deletions test/function/target/stream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Expand Down Expand Up @@ -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));

Expand Down
4 changes: 1 addition & 3 deletions tools/check_headers/stumpless.yml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
12 changes: 12 additions & 0 deletions tools/cmake/test.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit e292883

Please sign in to comment.