diff --git a/package.json b/package.json index 1d865fb..064de58 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@airbnb/node-memwatch", "description": "Keep an eye on your memory usage, and discover and isolate leaks.", - "version": "2.0.0", + "version": "2.0.1", "author": "Lloyd Hilaiel (http://lloyd.io)", "engines": { "node": ">= 10.0" diff --git a/src/memwatch.cc b/src/memwatch.cc index 26b9c64..c5e5507 100644 --- a/src/memwatch.cc +++ b/src/memwatch.cc @@ -16,13 +16,26 @@ #include // for pow #include // for time -#include +// #include +#include // use chrono instead of sys/time.h using namespace v8; using namespace node; Local g_context; +// define gettimeofday which uses chrono, earlier it was defined in header sys/time.h which is now deprecated +int gettimeofday(struct timeval* tp, struct timezone* tzp) { + namespace sc = std::chrono; + sc::system_clock::duration d = sc::system_clock::now().time_since_epoch(); + sc::seconds s = sc::duration_cast(d); + tp->tv_sec = s.count(); + tp->tv_usec = sc::duration_cast(d - s).count(); + + return 0; +} + + class UponGCCallback : public Nan::AsyncResource { public: UponGCCallback(v8::Local callback_) : Nan::AsyncResource("memwatch:upon_gc") {