Created
April 9, 2012 15:45
-
-
Save j0sh/2344350 to your computer and use it in GitHub Desktop.
rtmpd: Add Variant constructor for bytearrays.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| From ff54f597dddf014f215a0e6ed4fe54bac23b9efb Mon Sep 17 00:00:00 2001 | |
| From: Josh Allmann <joshua.allmann@gmail.com> | |
| Date: Thu, 5 Apr 2012 13:52:37 -0700 | |
| Subject: [PATCH] -- Add Variant constructor for bytearrays. | |
| --- | |
| sources/common/include/utils/misc/variant.h | 1 + | |
| sources/common/src/utils/misc/variant.cpp | 8 ++++++++ | |
| 2 files changed, 9 insertions(+), 0 deletions(-) | |
| diff --git a/sources/common/include/utils/misc/variant.h b/sources/common/include/utils/misc/variant.h | |
| index dfee3f1..e7a4f01 100644 | |
| --- a/sources/common/include/utils/misc/variant.h | |
| +++ b/sources/common/include/utils/misc/variant.h | |
| @@ -126,6 +126,7 @@ public: | |
| Variant(const char *pValue); | |
| Variant(const string &value); | |
| + Variant(const uint8_t *pValue, uint32_t len); | |
| virtual ~Variant(); | |
| diff --git a/sources/common/src/utils/misc/variant.cpp b/sources/common/src/utils/misc/variant.cpp | |
| index e6af05b..c89dcc0 100644 | |
| --- a/sources/common/src/utils/misc/variant.cpp | |
| +++ b/sources/common/src/utils/misc/variant.cpp | |
| @@ -188,6 +188,14 @@ Variant::Variant(const string &val) { | |
| _value.s = new string(val); | |
| } | |
| +Variant::Variant(const uint8_t *pVal, uint32_t len) { | |
| + CONSTRUCTOR; | |
| + _type = V_BYTEARRAY; | |
| + memset(&_value, 0, sizeof (_value)); | |
| + DYNAMIC_ALLOC("_value.s"); | |
| + _value.s = new string((const char*)pVal, (size_t)len); | |
| +} | |
| + | |
| Variant::~Variant() { | |
| DESTRUCTOR; | |
| Reset(); | |
| -- | |
| 1.7.5.4 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment