Skip to content
GitLab
Explorer
Connexion
Navigation principale
Rechercher ou aller à…
Projet
Vivy
Gestion
Activité
Membres
Labels
Programmation
Tickets
Tableaux des tickets
Jalons
Wiki
Wiki externe
Code
Requêtes de fusion
Dépôt
Branches
Validations
Étiquettes
Graphe du dépôt
Comparer les révisions
Compilation
Pipelines
Jobs
Planifications de pipeline
Artéfacts
Aide
Aide
Support
Documentation de GitLab
Comparer les forfaits GitLab
Forum de la communauté
Contribuer à GitLab
Donner votre avis
Raccourcis clavier
?
Extraits de code
Groupes
Projets
Afficher davantage de fils d'Ariane
Elliu
Vivy
Validations
4cdb4e9d
Vérifiée
Valider
4cdb4e9d
rédigé
3 years ago
par
Kubat
Parcourir les fichiers
Options
Téléchargements
Correctifs
Plain Diff
LIB: Add a way to do the `if (ptr) free(ptr)` in a generic way
parent
af777881
Aucune branche associée trouvée
Aucune étiquette associée trouvée
1 requête de fusion
!18
Implement the VivyDocument specification
Modifications
2
Masquer les modifications d'espaces
En ligne
Côte à côte
Affichage de
2 fichiers modifiés
src/Lib/Audio.hh
+14
-23
14 ajouts, 23 suppressions
src/Lib/Audio.hh
src/Lib/Utils.hh
+16
-0
16 ajouts, 0 suppression
src/Lib/Utils.hh
avec
30 ajouts
et
23 suppressions
src/Lib/Audio.hh
+
14
−
23
Voir le fichier @
4cdb4e9d
...
@@ -37,24 +37,17 @@ public:
...
@@ -37,24 +37,17 @@ public:
class
Stream
final
{
class
Stream
final
{
VIVY_UNMOVABLE_OBJECT
(
Stream
)
VIVY_UNMOVABLE_OBJECT
(
Stream
)
// All the needed deleters
static
inline
Utils
::
DeleterFunctionType
<
double
>
dataDeleter
=
static
inline
constexpr
auto
codecContexteleter
=
[](
AVCodecContext
*
ptr
)
noexcept
->
void
{
std
::
bind_front
(
Utils
::
freePtrIfNotNull
<
double
>
,
av_free
);
if
(
ptr
)
avcodec_free_context
(
&
ptr
);
static
inline
Utils
::
DeleterFunctionType
<
AVCodecContext
>
codecContexteleter
=
};
std
::
bind_front
(
Utils
::
freePPtrIfNotNull
<
AVCodecContext
>
,
avcodec_free_context
);
static
constexpr
inline
auto
dataDeleter
=
[](
double
*
ptr
)
noexcept
->
void
{
if
(
ptr
)
static
inline
Utils
::
DeleterFunctionType
<
AVFrame
>
avFrameDeleter
=
av_free
(
ptr
);
std
::
bind_front
(
Utils
::
freePPtrIfNotNull
<
AVFrame
>
,
av_frame_free
);
};
static
constexpr
inline
auto
avFrameDeleter
=
[](
AVFrame
*
ptr
)
noexcept
->
void
{
static
inline
Utils
::
DeleterFunctionType
<
SwrContext
>
swrContenxtDeleter
=
if
(
ptr
)
std
::
bind_front
(
Utils
::
freePPtrIfNotNull
<
SwrContext
>
,
swr_free
);
av_frame_free
(
&
ptr
);
};
static
constexpr
inline
auto
swrContenxtDeleter
=
[](
SwrContext
*
swr
)
noexcept
->
void
{
if
(
swr
)
swr_free
(
&
swr
);
};
// All the used types
// All the used types
using
AVCodecContextPtr
=
std
::
unique_ptr
<
AVCodecContext
,
decltype
(
codecContexteleter
)
>
;
using
AVCodecContextPtr
=
std
::
unique_ptr
<
AVCodecContext
,
decltype
(
codecContexteleter
)
>
;
...
@@ -135,11 +128,9 @@ public:
...
@@ -135,11 +128,9 @@ public:
private
:
private
:
// Regarding the format
// Regarding the format
static
inline
constexpr
auto
avFormatContextDeleter
=
static
inline
Utils
::
DeleterFunctionType
<
AVFormatContext
>
avFormatContextDeleter
=
[](
AVFormatContext
*
ptr
)
noexcept
->
void
{
std
::
bind_front
(
Utils
::
freePtrIfNotNull
<
AVFormatContext
>
,
avformat_free_context
);
if
(
ptr
)
avformat_free_context
(
ptr
);
};
using
AVFormatContextPtr
=
std
::
unique_ptr
<
AVFormatContext
,
decltype
(
avFormatContextDeleter
)
>
;
using
AVFormatContextPtr
=
std
::
unique_ptr
<
AVFormatContext
,
decltype
(
avFormatContextDeleter
)
>
;
AVFormatContextPtr
format
{
avformat_alloc_context
(),
avFormatContextDeleter
};
AVFormatContextPtr
format
{
avformat_alloc_context
(),
avFormatContextDeleter
};
...
...
Ce diff est replié.
Cliquez pour l'agrandir.
src/Lib/Utils.hh
+
16
−
0
Voir le fichier @
4cdb4e9d
...
@@ -172,6 +172,22 @@ QString getBaseName(const QString &) noexcept;
...
@@ -172,6 +172,22 @@ QString getBaseName(const QString &) noexcept;
void
writeAssertLocation
(
const
char
*
msg
);
void
writeAssertLocation
(
const
char
*
msg
);
template
<
typename
T
>
using
DeleterFunctionType
=
const
std
::
function
<
void
(
T
*
)
>
;
template
<
typename
Type
>
static
inline
void
freePtrIfNotNull
(
DeleterFunctionType
<
Type
>
callback
,
Type
*
ptr
)
noexcept
{
if
(
ptr
!=
nullptr
)
callback
(
ptr
);
}
template
<
typename
Type
>
static
inline
void
freePPtrIfNotNull
(
DeleterFunctionType
<
Type
*>
callback
,
Type
*
ptr
)
noexcept
{
if
(
ptr
!=
nullptr
)
callback
(
&
ptr
);
}
struct
OsSpecificAspects
final
{
struct
OsSpecificAspects
final
{
private:
private:
OsSpecificAspects
()
{}
OsSpecificAspects
()
{}
...
...
Ce diff est replié.
Cliquez pour l'agrandir.
Kubat
@martin2018
mentioned in commit
49bbb2d7
·
3 years ago
mentioned in commit
49bbb2d7
mentioned in commit 49bbb2d7735cc74c76db58ac9ecfd54346481d23
Afficher/masquer la liste des validations
Aperçu
0%
Chargement en cours
Veuillez réessayer
ou
joindre un nouveau fichier
.
Annuler
You are about to add
0
people
to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Enregistrer le commentaire
Annuler
Veuillez vous
inscrire
ou vous
se connecter
pour commenter