E-MailRelay
gcleanup_win32.cpp
Go to the documentation of this file.
1//
2// Copyright (C) 2001-2023 Graeme Walker <graeme_walker@users.sourceforge.net>
3//
4// This program is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation, either version 3 of the License, or
7// (at your option) any later version.
8//
9// This program is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.
13//
14// You should have received a copy of the GNU General Public License
15// along with this program. If not, see <http://www.gnu.org/licenses/>.
16// ===
17///
18/// \file gcleanup_win32.cpp
19///
20
21#include "gdef.h"
22#include "gcleanup.h"
23#include <cstring> // _strdup()
24
26{
27 // no-op
28}
29
30void G::Cleanup::add( bool (*)(SignalSafe,const char*) , const char * )
31{
32 // not implemented
33}
34
35void G::Cleanup::atexit( bool )
36{
37 // not implemented
38}
39
40void G::Cleanup::block() noexcept
41{
42 // not implemented
43}
44
45void G::Cleanup::release() noexcept
46{
47 // not implemented
48}
49
50namespace
51{
52 const char * strdup_ignore_leaks( const char * p )
53 {
54 return _strdup( p ) ; // NOLINT
55 }
56}
57
58const char * G::Cleanup::strdup( const char * p )
59{
60 return strdup_ignore_leaks( p ) ;
61}
62
63const char * G::Cleanup::strdup( const std::string & s )
64{
65 return strdup_ignore_leaks( s.c_str() ) ;
66}
static const char * strdup(const char *)
A strdup() function that makes it clear in the stack trace that leaks are expected.
static void atexit(bool active=true)
Ensures that the cleanup functions are also called via atexit(), in addition to abnormal-termination ...
static void release() noexcept
Releases block()ed signals.
static void add(bool(*fn)(SignalSafe, const char *), const char *arg)
Adds the given handler to the list of handlers that are to be called when the process terminates abno...
static void block() noexcept
Temporarily blocks signals until release()d.
static void init()
An optional early-initialisation function. May be called more than once.