@@ -48,48 +48,53 @@ namespace NodeLibcurl {
4848 typedef v8::Local<v8::Value> ADDON_REGISTER_FUNCTION_ARGS2_TYPE;
4949#endif
5050
51- #define CURL_MODULE_INIT ( name ) \
51+ #define NODE_LIBCURL_MODULE_INIT ( name ) \
5252 void name ( Nan::ADDON_REGISTER_FUNCTION_ARGS_TYPE exports, ADDON_REGISTER_FUNCTION_ARGS2_TYPE module )
5353
54+ #define NODE_LIBCURL_ADJUST_MEM ( size ) if ( !isLibcurlBuiltWithThreadedResolver ) AdjustMemory( size )
55+
5456 // store mapping from the CURL[*] constants that can be used in js
5557 struct CurlConstant
5658 {
5759 const char *name;
5860 int64_t value;
5961 };
6062
63+ extern ssize_t addonAllocatedMemory;
64+ extern bool isLibcurlBuiltWithThreadedResolver;
65+
6166 template <typename T>
6267 using deleted_unique_ptr = std::unique_ptr<T, std::function<void ( T* )>>;
6368
64- const extern std::vector<CurlConstant> curlConstAuth;
65- const extern std::vector<CurlConstant> curlConstProtocol;
66- const extern std::vector<CurlConstant> curlConstPause;
67- const extern std::vector<CurlConstant> curlConstHttp;
68- const extern std::vector<CurlConstant> curlConstHeader;
69-
70- const extern std::vector<CurlConstant> curlOptionNotImplemented;
71- const extern std::vector<CurlConstant> curlOptionInteger;
72- const extern std::vector<CurlConstant> curlOptionString;
73- const extern std::vector<CurlConstant> curlOptionFunction;
74- const extern std::vector<CurlConstant> curlOptionLinkedList;
75- const extern std::vector<CurlConstant> curlOptionHttpPost;
76- const extern std::vector<CurlConstant> curlOptionSpecific;
77-
78- const extern std::vector<CurlConstant> curlInfoNotImplemented;
79- const extern std::vector<CurlConstant> curlInfoString;
80- const extern std::vector<CurlConstant> curlInfoDouble;
81- const extern std::vector<CurlConstant> curlInfoInteger;
82- const extern std::vector<CurlConstant> curlInfoSocket;
83- const extern std::vector<CurlConstant> curlInfoLinkedList;
84-
85- const extern std::vector<CurlConstant> curlMultiOptionNotImplemented;
86- const extern std::vector<CurlConstant> curlMultiOptionInteger;
87- const extern std::vector<CurlConstant> curlMultiOptionStringArray;
88-
89- const extern std::vector<CurlConstant> curlCode;
69+ extern const std::vector<CurlConstant> curlConstAuth;
70+ extern const std::vector<CurlConstant> curlConstProtocol;
71+ extern const std::vector<CurlConstant> curlConstPause;
72+ extern const std::vector<CurlConstant> curlConstHttp;
73+ extern const std::vector<CurlConstant> curlConstHeader;
74+
75+ extern const std::vector<CurlConstant> curlOptionNotImplemented;
76+ extern const std::vector<CurlConstant> curlOptionInteger;
77+ extern const std::vector<CurlConstant> curlOptionString;
78+ extern const std::vector<CurlConstant> curlOptionFunction;
79+ extern const std::vector<CurlConstant> curlOptionLinkedList;
80+ extern const std::vector<CurlConstant> curlOptionHttpPost;
81+ extern const std::vector<CurlConstant> curlOptionSpecific;
82+
83+ extern const std::vector<CurlConstant> curlInfoNotImplemented;
84+ extern const std::vector<CurlConstant> curlInfoString;
85+ extern const std::vector<CurlConstant> curlInfoDouble;
86+ extern const std::vector<CurlConstant> curlInfoInteger;
87+ extern const std::vector<CurlConstant> curlInfoSocket;
88+ extern const std::vector<CurlConstant> curlInfoLinkedList;
89+
90+ extern const std::vector<CurlConstant> curlMultiOptionNotImplemented;
91+ extern const std::vector<CurlConstant> curlMultiOptionInteger;
92+ extern const std::vector<CurlConstant> curlMultiOptionStringArray;
93+
94+ extern const std::vector<CurlConstant> curlCode;
9095
9196 // export Curl to js
92- CURL_MODULE_INIT ( Initialize );
97+ NODE_LIBCURL_MODULE_INIT ( Initialize );
9398
9499 // js exported Methods
95100 NAN_METHOD ( GetVersion );
@@ -99,6 +104,7 @@ namespace NodeLibcurl {
99104 // helper methods
100105 int32_t IsInsideCurlConstantStruct ( const std::vector<CurlConstant> &curlConstants, const v8::Local<v8::Value> &searchFor );
101106 void ThrowError ( const char *message, const char *reason = nullptr );
107+ void AdjustMemory ( ssize_t size );
102108
103109}
104110#endif
0 commit comments