Commit Graph

65 Commits

Author SHA1 Message Date
Winlin
23d2602c34
UniquePtr: Support SrsUniquePtr to replace SrsAutoFree. v6.0.136 (#4109)
To manage an object:

```cpp
// Before
MyClass* ptr = new MyClass();
SrsAutoFree(MyClass, ptr);
ptr->do_something();

// Now
SrsUniquePtr<MyClass> ptr(new MyClass());
ptr->do_something();
```

To manage an array of objects:

```cpp
// Before
char* ptr = new char[10];
SrsAutoFreeA(char, ptr);
ptr[0] = 0xf;

// Now
SrsUniquePtr<char[]> ptr(new char[10]);
ptr[0] = 0xf;
```

In fact, SrsUniquePtr is a limited subset of SrsAutoFree, mainly
managing pointers and arrays. SrsUniquePtr is better than SrsAutoFree
because it has the same API to standard unique ptr.

```cpp
SrsUniquePtr<MyClass> ptr(new MyClass());
ptr->do_something();
MyClass* p = ptr.get();
```

SrsAutoFree actually uses a pointer to a pointer, so it can be set to
NULL, allowing the pointer's value to be changed later (this usage is
different from SrsUniquePtr).

```cpp
// OK to free ptr correctly.
MyClass* ptr;
SrsAutoFree(MyClass, ptr);
ptr = new MyClass();

// Crash because ptr is an invalid pointer.
MyClass* ptr;
SrsUniquePtr<MyClass> ptr(ptr);
ptr = new MyClass();
```

Additionally, SrsAutoFreeH can use specific release functions, which
SrsUniquePtr does not support.

---------

Co-authored-by: Jacob Su <suzp1984@gmail.com>
2024-07-09 10:29:36 +08:00
winlin
2a2da2253f Switch to 2013-2024. v6.0.109 2024-01-01 10:51:24 +08:00
winlin
29eff1a242 Refine LICENSE. 2023-10-23 14:33:19 +08:00
winlin
c46ef81ff2 SRS5: Update license date to 2023. v5.0.123
PICK 72f8ed4916
2023-01-01 08:56:20 +08:00
Winlin
368356c223
Support address sanitizer for utest and fix some leaks. (#3242)
* MP4: Fix memory leak when error.

* Kernel: Support free global objects for utest.

* HTTP: Fix memory leak when error.

* MP4: Support more sample rate for audio.

* RTMP: Support free field for utest.

* UTest: Support address sanitizer.
2022-11-18 11:19:01 +08:00
winlin
d117145b95 Update date from 2021 to 2022. 2022-06-20 19:22:25 +08:00
winlin
d5c86dc5fa Switch LICENSE from MIT to **MIT or MulanPSL-2.0**. v5.0.21 2022-01-13 18:40:22 +08:00
winlin
665b5f48f7 Squash: JSON: Support escape special chars. (#1758) 2021-10-20 09:16:18 +08:00
Winlin
c8a1e0f3da
Refine AUTHORS.txt to AUTHORS.md, etc. 5.0.8 (#2464)
* Refine AUTHORS.txt to AUTHORS.md, etc. 5.0.8

* Update README.md

* Update README.md

* Refine format for AUTHORS.md
2021-07-08 14:30:47 +08:00
winlin
15901cacee SquashSRS4: Use SPDX-License-Identifier: MIT. 5.0.3 2021-05-31 13:42:20 +08:00
winlin
8b74c7cb89 SquashSRS4: Happy 2021 2021-04-16 09:29:43 +08:00
winlin
8c1eca98b0 Merge SRS3.0 2020-10-31 19:25:56 +08:00
winlin
b348539687 Remove some global elements for debugging. 3.0.152 2020-10-31 17:53:00 +08:00
winlin
8933e6f429 Fix utest build failed. 2020-05-05 08:35:16 +08:00
winlin
244fefa8c5 Update utest 2020-04-21 15:06:57 +08:00
winlin
d783a12f89 Happy 2020 2019-12-30 10:10:35 +08:00
winlin
f99ca04bd5 Cover JSON codec. 3.0.62 2019-10-23 08:59:30 +08:00
winlin
1b2449ca3f Cover JSON codec. 3.0.62 2019-10-23 08:47:02 +08:00
winlin
48970389ba Cover JSON codec. 3.0.62 2019-10-22 10:06:12 +08:00
winlin
e816ac28d2 Cover JSON codec. 3.0.62 2019-10-22 10:02:37 +08:00
winlin
1ebec34d5b Cover JSON codec. 3.0.62 2019-10-22 09:58:09 +08:00
winlin
e683f07715 Cover JSON codec. 3.0.62 2019-10-22 09:01:29 +08:00
winlin
c7602d8cee Cover JSON codec. 3.0.62 2019-10-22 08:54:29 +08:00
winlin
aee704fd1f Cover AMF0 codec. 3.0.61 2019-10-22 08:30:46 +08:00
winlin
0a9659b749 Cover AMF0 codec. 3.0.61 2019-10-21 09:29:42 +08:00
winlin
232024ef67 AMF0: Refine utest 2019-10-18 08:54:59 +08:00
winlin
9542cd2ba5 AMF0: Refine utest 2019-10-18 08:54:13 +08:00
winlin
b2d1d84634 Change to 2019 2019-01-01 21:37:28 +08:00
winlin
ca1395a807 Change date from 2017 to 2018 2018-01-07 10:58:53 +08:00
winlin
db08f1586c For #913, APP support complex error. 2018-01-01 22:32:54 +08:00
winlin
0a57a46016 Refine LICENSE 2017-03-25 21:29:29 +08:00
winlin
7ac932cfa0 update to 2013-2017 2016-12-16 11:57:25 +08:00
winlin
d0c74fa7cd update 2015 to 2016 2015-12-23 11:35:40 +08:00
winlin
01c46bdbfd rename org simle-rtmp-server to ossrs 2015-11-11 10:45:45 +08:00
winlin
1ffd5fd455 rename org simple-rtmp-server to ossrs 2015-11-11 10:37:50 +08:00
winlin
0e52fc6d5b rename SrsStream to SrsBuffer 2015-09-22 08:57:31 +08:00
winlin
a4f51564db rename kernel stream to buffer 2015-09-22 08:48:55 +08:00
winlin
b23e196f20 migarate from winlinvip to srs org, move the copyright to srs org. 2015-04-29 17:38:23 +08:00
winlin
569596c10d update copyright, from 2013 to 2015 2014-12-31 20:32:09 +08:00
winlin
798f9139a4 add reload utest. 2014-08-05 09:16:25 +08:00
winlin
7b24788445 for bug #143, build on centos5. 2014-08-02 22:18:39 +08:00
winlin
e5e2729967 refine amf0 and handshake code, add comments to utest. 2014-07-06 17:25:25 +08:00
winlin
d22e7cab0a add comments to amf0 2014-07-06 16:51:07 +08:00
winlin
7805f7b12a add prefix Protocol to AMF0 and Handshake utest 2014-07-05 21:30:11 +08:00
winlin
5a41b1b538 finish kernel utest. to 0.9.149 2014-07-05 21:22:20 +08:00
winlin
e6c03c6d6d complete the amf0 strict array utest 2014-06-07 20:40:02 +08:00
winlin
5a06909d75 update amf0 strict array test, fix bug of count zero init 2014-06-07 20:01:11 +08:00
winlin
dc66c525fd refine autofree, only free object, never free arrays 2014-05-14 09:41:41 +08:00
winlin
c85dde7f3f substitute all TAB with 4spaces. 2014-03-18 11:32:58 +08:00
winlin
387be8fa3b change to 0.9.15, finish amf0 utest 2014-03-09 20:37:20 +08:00