From 448e170ef8101f10e2f27d965d95ee5f51e04ecd Mon Sep 17 00:00:00 2001 From: Benjamin Gilbert Date: Fri, 13 Oct 2023 10:05:52 -0500 Subject: [PATCH] Deprecate dcm_init() We can't remove it without breaking ABI, but we can avoid giving the impression that applications need to call it. --- doc/source/usage.rst | 5 ----- include/dicom/dicom.h | 17 +++++++++++------ tests/check_dicom.c | 2 -- tools/dcm-dump.c | 2 -- tools/dcm-getframe.c | 2 -- 5 files changed, 11 insertions(+), 17 deletions(-) diff --git a/doc/source/usage.rst b/doc/source/usage.rst index cae5801..fb68771 100644 --- a/doc/source/usage.rst +++ b/doc/source/usage.rst @@ -137,11 +137,6 @@ locked to prevent subsequent modification via :c:func:`dcm_sequence_lock()`. A Sequence is automatically locked when used as a value in a Data Element with Value Representation SQ (Sequence of Items). -Call :c:func:`dcm_init()` from the main thread during program startup for -libdicom initialisation to be threadsafe. If you do not call this, it will be -triggered for you on first use, but in this case libdicom initialisation will -not be threadsafe. - Error handling ++++++++++++++ diff --git a/include/dicom/dicom.h b/include/dicom/dicom.h index 1a14c0e..e4e04fe 100644 --- a/include/dicom/dicom.h +++ b/include/dicom/dicom.h @@ -116,15 +116,20 @@ typedef struct _DcmSequence DcmSequence; /** * Start up libdicom. * - * Call this from the main thread during program startup for libdicom to be - * threadsafe. - * - * If you don't do this, libdicom will attempt to call it for you in a safe - * way, but cannot guarantee this on all platforms and with all compilers, and - * therefore cannot guarantee thread safety. + * Call this from the main thread during program startup. * * This function can be called many times. + * + * .. deprecated:: 1.0.6 + * Calling this function is no longer necessary. */ +#ifndef BUILDING_LIBDICOM +#if defined(_MSC_VER) +__declspec(deprecated("dcm_init() no longer needs to be called")) +#elif defined(__GNUC__) +__attribute__((deprecated("dcm_init() no longer needs to be called"))) +#endif +#endif DCM_EXTERN void dcm_init(void); diff --git a/tests/check_dicom.c b/tests/check_dicom.c index afe4081..56e9a85 100644 --- a/tests/check_dicom.c +++ b/tests/check_dicom.c @@ -849,8 +849,6 @@ static Suite *create_file_suite(void) int main(void) { - dcm_init(); - SRunner *runner = srunner_create(create_main_suite()); srunner_add_suite(runner, create_data_suite()); srunner_add_suite(runner, create_file_suite()); diff --git a/tools/dcm-dump.c b/tools/dcm-dump.c index 2678deb..b8624ad 100644 --- a/tools/dcm-dump.c +++ b/tools/dcm-dump.c @@ -14,8 +14,6 @@ int main(int argc, char *argv[]) { int i, c; - dcm_init(); - while ((c = dcm_getopt(argc, argv, "h?Vv")) != -1) { switch (c) { case 'h': diff --git a/tools/dcm-getframe.c b/tools/dcm-getframe.c index d43628b..ce5b0b9 100644 --- a/tools/dcm-getframe.c +++ b/tools/dcm-getframe.c @@ -20,8 +20,6 @@ int main(int argc, char *argv[]) int c; - dcm_init(); - while ((c = dcm_getopt(argc, argv, "h?Vvo:")) != -1) { switch (c) { case 'h':