Skip to content

Commit 20e9100

Browse files
Merge pull request #157 from justadudewhohacks/nanbuffer-freecallback
Nanbuffer freecallback
2 parents ac069dd + 69f2087 commit 20e9100

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,15 +134,14 @@ $ npm run electron-rebuild
134134

135135
Require it in the application:
136136
``` javascript
137-
const electron = require('electron');
138-
const cv = electron.remote.require('opencv4nodejs');
137+
const cv = require('opencv4nodejs');
139138
```
140139

141140
<a name="usage-with-nwjs"></a>
142141

143142
## Usage with NW.js
144143

145-
Any native modules, including opencv4nodejs, must be recompiled to be used with [NW.js](https://nwjs.io/). Instructions on how to do this are available in the **[Use Native Modules] (http://docs.nwjs.io/en/latest/For%20Users/Advanced/Use%20Native%20Node%20Modules/)** section of the the NW.js documentation.
144+
Any native modules, including opencv4nodejs, must be recompiled to be used with [NW.js](https://nwjs.io/). Instructions on how to do this are available in the **[Use Native Modules] (http://docs.nwjs.io/en/latest/For%20Users/Advanced/Use%20Native%20Node%20Modules/)** section of the the NW.js documentation.
146145

147146
Once recompiled, the module can be installed and required as usual:
148147

cc/core/Mat.cc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,8 +273,12 @@ struct Mat::GetDataWorker : SimpleWorker {
273273
return "";
274274
}
275275

276+
static void freeBufferCallback(char* data, void* hint) {
277+
free(data);
278+
}
279+
276280
FF_VAL getReturnValue() {
277-
return Nan::NewBuffer(data, size).ToLocalChecked();
281+
return Nan::NewBuffer(data, size, freeBufferCallback, 0).ToLocalChecked();
278282
}
279283
};
280284

0 commit comments

Comments
 (0)