mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-21 18:59:21 +00:00
Improve Memory Management of Result class
The way in which the Result class is used in Dawn can be fragile with respect to memory management because the caller of AcquireError must know they need to delete the returned pointer or a memory leak will occur. We've had a couple of instances where developers have accidentally left out the delete call and managed to get past code review. This CL changes the Result class so that it assumes the error is allocated on the heap and forces the caller to use unique_ptr when calling AcquireError. Bug:dawn:320 Change-Id: I13ec953b0c37eaafbd6ce93c2f719b4743676acb Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/14960 Reviewed-by: Austin Eng <enga@chromium.org> Reviewed-by: Corentin Wallez <cwallez@chromium.org> Commit-Queue: Rafael Cintron <rafael.cintron@microsoft.com>
This commit is contained in:
committed by
Commit Bot service account
parent
4950095ac9
commit
69c68d01b2
@@ -33,7 +33,11 @@ namespace dawn_native {
|
||||
|
||||
class ErrorData {
|
||||
public:
|
||||
ErrorData();
|
||||
static std::unique_ptr<ErrorData> Create(InternalErrorType type,
|
||||
std::string message,
|
||||
const char* file,
|
||||
const char* function,
|
||||
int line);
|
||||
ErrorData(InternalErrorType type, std::string message);
|
||||
|
||||
struct BacktraceRecord {
|
||||
|
||||
Reference in New Issue
Block a user