From bb6465fd385ddcd030b7c7a002b495be9c5eeff2 Mon Sep 17 00:00:00 2001 From: Joshua Granick Date: Tue, 30 Aug 2016 15:55:36 -0700 Subject: [PATCH] Import @vroad byte pinning for C# --- project/Build.xml | 1 + project/include/utils/Bytes.h | 1 + project/src/utils/Bytes.cpp | 29 ++++++++++++++++++++++++----- 3 files changed, 26 insertions(+), 5 deletions(-) diff --git a/project/Build.xml b/project/Build.xml index 2ee45b480..e5cd401ae 100644 --- a/project/Build.xml +++ b/project/Build.xml @@ -44,6 +44,7 @@ +
diff --git a/project/include/utils/Bytes.h b/project/include/utils/Bytes.h index 58035ebed..43af10f72 100644 --- a/project/include/utils/Bytes.h +++ b/project/include/utils/Bytes.h @@ -29,6 +29,7 @@ namespace lime { unsigned char *_data; int _length; + value _pin; AutoGCRoot *_root; value _value; diff --git a/project/src/utils/Bytes.cpp b/project/src/utils/Bytes.cpp index b689d47b9..087098915 100644 --- a/project/src/utils/Bytes.cpp +++ b/project/src/utils/Bytes.cpp @@ -1,3 +1,4 @@ +#include #include #include @@ -39,8 +40,9 @@ namespace lime { _data = 0; _length = 0; - _value = 0; + _pin = 0; _root = 0; + _value = 0; } @@ -51,8 +53,9 @@ namespace lime { _data = 0; _length = 0; - _value = 0; + _pin = 0; _root = 0; + _value = 0; Resize (size); @@ -65,8 +68,9 @@ namespace lime { _data = 0; _length = 0; - _value = 0; + _pin = 0; _root = 0; + _value = 0; Set (bytes); @@ -79,8 +83,9 @@ namespace lime { _data = 0; _length = 0; - _value = 0; + _pin = 0; _root = 0; + _value = 0; FILE_HANDLE *file = lime::fopen (path, "rb"); @@ -112,8 +117,9 @@ namespace lime { _data = 0; _length = 0; - _value = 0; + _pin = 0; _root = 0; + _value = 0; Set (data); @@ -122,6 +128,12 @@ namespace lime { Bytes::~Bytes () { + if (_pin) { + + EXT_unpin_buffer (_pin); + + } + if (_root) { delete _root; @@ -298,6 +310,13 @@ namespace lime { if (_value) { + if (!_pin && HAS_pin_buffer ()) { + + buffer b = val_to_buffer (val_field (_value, id_b)); + _pin = EXT_pin_buffer (b); + + } + return _value; } else {