mirror of
https://gitlab.uni-freiburg.de/opensourcevdi/spice
synced 2026-01-03 15:58:43 +00:00
Introduce some utilities for C++
red::add_ref will be used to increment a reference counter and return the object pointer. Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
This commit is contained in:
parent
77af39d6b5
commit
3a05720eaa
@ -96,6 +96,7 @@ libserver_la_SOURCES = \
|
||||
cursor-channel-client.cpp \
|
||||
cursor-channel-client.h \
|
||||
cursor-channel.h \
|
||||
utils.hpp \
|
||||
dcc.cpp \
|
||||
dcc.h \
|
||||
dcc-private.h \
|
||||
|
||||
@ -56,6 +56,7 @@ spice_server_sources = [
|
||||
'cursor-channel-client.cpp',
|
||||
'cursor-channel-client.h',
|
||||
'cursor-channel.h',
|
||||
'utils.hpp',
|
||||
'dcc.cpp',
|
||||
'dcc.h',
|
||||
'dcc-private.h',
|
||||
|
||||
37
server/utils.hpp
Normal file
37
server/utils.hpp
Normal file
@ -0,0 +1,37 @@
|
||||
/*
|
||||
Copyright (C) 2019 Red Hat, Inc.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/* Generic utilities for C++
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace red {
|
||||
|
||||
|
||||
template <typename T>
|
||||
inline T* add_ref(T* p)
|
||||
{
|
||||
if (p) {
|
||||
p->ref();
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
|
||||
} // namespace red
|
||||
Loading…
Reference in New Issue
Block a user