fix: Fix crash in toArrayBuffer() by properly acquiring a reference on AHardwareBuffer* (#2490)
				
					
				
			* fix: Fix crash in `toArrayBuffer()` by properly acquiring a reference on `AHardwareBuffer*` * Format * Update Podfile.lock
This commit is contained in:
		
							
								
								
									
										34
									
								
								package/cpp/FinalAction.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										34
									
								
								package/cpp/FinalAction.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,34 @@ | ||||
| // | ||||
| //  MutableRawBuffer.h | ||||
| //  VisionCamera | ||||
| // | ||||
| //  Created by Marc Rousavy on 17.01.24. | ||||
| //  Copyright © 2024 mrousavy. All rights reserved. | ||||
| // | ||||
|  | ||||
| #pragma once | ||||
|  | ||||
| namespace vision { | ||||
|  | ||||
| template <typename F> struct FinalAction { | ||||
|  | ||||
| public: | ||||
|   FinalAction(F f) : clean_{f} {} | ||||
|   ~FinalAction() { | ||||
|     if (enabled_) | ||||
|       clean_(); | ||||
|   } | ||||
|   void disable() { | ||||
|     enabled_ = false; | ||||
|   }; | ||||
|  | ||||
| private: | ||||
|   F clean_; | ||||
|   bool enabled_ = true; | ||||
| }; | ||||
|  | ||||
| } // namespace vision | ||||
|  | ||||
| template <typename F> vision::FinalAction<F> finally(F f) { | ||||
|   return vision::FinalAction<F>(std::move(f)); | ||||
| } | ||||
		Reference in New Issue
	
	Block a user