Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ref

Package Overview
Dependencies
Maintainers
1
Versions
48
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ref - npm Package Compare versions

Comparing version 1.1.1 to 1.1.2

6

History.md
1.1.2 / 2015-09-19
==================
* CString: allow a Buffer to be used as backing store in `set()` (https://github.com/node-ffi/node-ffi/issues/169)
* travis, appveyor: test Node.js v4
1.1.1 / 2015-09-14

@@ -3,0 +9,0 @@ ==================

16

lib/ref.js

@@ -1030,11 +1030,17 @@

, get: function get (buf, offset) {
var _buf = buf.readPointer(offset)
if (_buf.isNull()) {
var _buf = exports.readPointer(buf, offset)
if (exports.isNull(_buf)) {
return null
}
return _buf.readCString(0)
return exports.readCString(_buf, 0)
}
, set: function set (buf, offset, val) {
var _buf = exports.allocCString(val)
return buf.writePointer(_buf, offset)
var _buf
if (Buffer.isBuffer(val)) {
_buf = val
} else {
// assume string
_buf = exports.allocCString(val)
}
return exports.writePointer(buf, offset, _buf)
}

@@ -1041,0 +1047,0 @@ }

@@ -20,3 +20,3 @@ {

],
"version": "1.1.1",
"version": "1.1.2",
"license": "MIT",

@@ -23,0 +23,0 @@ "author": "Nathan Rajlich <nathan@tootallnate.net> (http://tootallnate.net)",

@@ -75,2 +75,3 @@

// another version of the same test
assert.strictEqual(null, ref.get(ref.NULL_POINTER, 0, ref.types.CString))

@@ -82,8 +83,18 @@ })

var buf = ref.alloc(ref.types.CString)
buf.writePointer(Buffer(str + '\0'))
buf.writePointer(new Buffer(str + '\0'))
assert.strictEqual(str, buf.deref())
})
// https://github.com/node-ffi/node-ffi/issues/169
it('should set a Buffer as backing store', function () {
var str = 'hey!'
var store = new Buffer(str + '\0')
var buf = ref.alloc(ref.types.CString)
ref.set(buf, 0, store)
assert.equal(str, ref.get(buf, 0))
})
})
})

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc