mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
Squash: Fix bugs
This commit is contained in:
parent
10d188faab
commit
716e578a19
382 changed files with 170096 additions and 220 deletions
|
@ -29,7 +29,7 @@
|
|||
#define RTMP_SIG_SRS_DOMAIN "ossrs.net"
|
||||
|
||||
// The current stable release.
|
||||
#define VERSION_STABLE 3
|
||||
#define VERSION_STABLE 4
|
||||
#define VERSION_STABLE_BRANCH SRS_XSTR(VERSION_STABLE) ".0release"
|
||||
|
||||
// For 32bit os, 2G big file limit for unistd io,
|
||||
|
|
|
@ -9,50 +9,62 @@
|
|||
|
||||
#include <srs_core.hpp>
|
||||
|
||||
/**
|
||||
* To free the instance in the current scope, for instance, MyClass* ptr,
|
||||
* which is a ptr and this class will:
|
||||
* 1. free the ptr.
|
||||
* 2. set ptr to NULL.
|
||||
*
|
||||
* Usage:
|
||||
* MyClass* po = new MyClass();
|
||||
* // ...... use po
|
||||
* SrsAutoFree(MyClass, po);
|
||||
*
|
||||
* Usage for array:
|
||||
* MyClass** pa = new MyClass*[size];
|
||||
* // ....... use pa
|
||||
* SrsAutoFreeA(MyClass*, pa);
|
||||
*
|
||||
* @remark the MyClass can be basic type, for instance, SrsAutoFreeA(char, pstr),
|
||||
* where the char* pstr = new char[size].
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
|
||||
// To free the instance in the current scope, for instance, MyClass* ptr,
|
||||
// which is a ptr and this class will:
|
||||
// 1. free the ptr.
|
||||
// 2. set ptr to NULL.
|
||||
//
|
||||
// Usage:
|
||||
// MyClass* po = new MyClass();
|
||||
// // ...... use po
|
||||
// SrsAutoFree(MyClass, po);
|
||||
//
|
||||
// Usage for array:
|
||||
// MyClass** pa = new MyClass*[size];
|
||||
// // ....... use pa
|
||||
// SrsAutoFreeA(MyClass*, pa);
|
||||
//
|
||||
// @remark the MyClass can be basic type, for instance, SrsAutoFreeA(char, pstr),
|
||||
// where the char* pstr = new char[size].
|
||||
// To delete object.
|
||||
#define SrsAutoFree(className, instance) \
|
||||
impl_SrsAutoFree<className> _auto_free_##instance(&instance, false)
|
||||
impl_SrsAutoFree<className> _auto_free_##instance(&instance, false, false)
|
||||
// To delete array.
|
||||
#define SrsAutoFreeA(className, instance) \
|
||||
impl_SrsAutoFree<className> _auto_free_array_##instance(&instance, true)
|
||||
impl_SrsAutoFree<className> _auto_free_array_##instance(&instance, true, false)
|
||||
// Use free instead of delete.
|
||||
#define SrsAutoFreeF(className, instance) \
|
||||
impl_SrsAutoFree<className> _auto_free_##instance(&instance, false, true)
|
||||
// The template implementation.
|
||||
template<class T>
|
||||
class impl_SrsAutoFree
|
||||
{
|
||||
private:
|
||||
T** ptr;
|
||||
bool is_array;
|
||||
bool _use_free;
|
||||
public:
|
||||
impl_SrsAutoFree(T** p, bool array) {
|
||||
impl_SrsAutoFree(T** p, bool array, bool use_free) {
|
||||
ptr = p;
|
||||
is_array = array;
|
||||
_use_free = use_free;
|
||||
}
|
||||
|
||||
virtual ~impl_SrsAutoFree() {
|
||||
if (ptr == NULL || *ptr == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (is_array) {
|
||||
delete[] *ptr;
|
||||
|
||||
if (_use_free) {
|
||||
free(*ptr);
|
||||
} else {
|
||||
delete *ptr;
|
||||
if (is_array) {
|
||||
delete[] *ptr;
|
||||
} else {
|
||||
delete *ptr;
|
||||
}
|
||||
}
|
||||
|
||||
*ptr = NULL;
|
||||
|
|
|
@ -9,6 +9,6 @@
|
|||
|
||||
#define VERSION_MAJOR 4
|
||||
#define VERSION_MINOR 0
|
||||
#define VERSION_REVISION 205
|
||||
#define VERSION_REVISION 212
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue