-
-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: memory leak when marshalling C string parameters (#127)
- Loading branch information
Showing
4 changed files
with
66 additions
and
3 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#include "OneByteStringResource.h" | ||
|
||
using namespace v8; | ||
|
||
namespace tns { | ||
|
||
OneByteStringResource::OneByteStringResource(const char* data, size_t length): | ||
data_(data), length_(length) { | ||
} | ||
|
||
OneByteStringResource::~OneByteStringResource() { | ||
delete this->data_; | ||
} | ||
|
||
const char* OneByteStringResource::data() const { | ||
return this->data_; | ||
} | ||
|
||
size_t OneByteStringResource::length() const { | ||
return this->length_; | ||
} | ||
|
||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#ifndef OneByteStringResource_h | ||
#define OneByteStringResource_h | ||
|
||
#include "Common.h" | ||
|
||
namespace tns { | ||
|
||
class OneByteStringResource : public v8::String::ExternalOneByteStringResource { | ||
public: | ||
OneByteStringResource(const char* data, size_t length); | ||
~OneByteStringResource() override; | ||
const char* data() const override; | ||
size_t length() const override; | ||
private: | ||
const char* data_; | ||
size_t length_; | ||
}; | ||
|
||
} | ||
|
||
#endif /* OneByteStringResource_h */ |
This file contains 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