mirror of
https://gitlab.uni-freiburg.de/opensourcevdi/spice
synced 2025-12-26 14:41:25 +00:00
red::add_ref will be used to increment a reference counter and return the object pointer. Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
38 lines
914 B
C++
38 lines
914 B
C++
/*
|
|
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
|