Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
node-sass
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
楚学文
node-sass
Commits
4abc7ddd
Commit
4abc7ddd
authored
Nov 17, 2014
by
Adeel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Code: Mitigates chances of memory leaks.
parent
739cc088
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
29 deletions
+15
-29
binding.cpp
src/binding.cpp
+15
-23
sass_context_wrapper.cpp
src/sass_context_wrapper.cpp
+0
-6
No files found.
src/binding.cpp
View file @
4abc7ddd
...
@@ -31,34 +31,28 @@ void ExtractOptions(Local<Object> options, void* cptr, sass_context_wrapper* ctx
...
@@ -31,34 +31,28 @@ void ExtractOptions(Local<Object> options, void* cptr, sass_context_wrapper* ctx
ctx_w
->
errorCallback
=
new
NanCallback
(
errorCallback
);
ctx_w
->
errorCallback
=
new
NanCallback
(
errorCallback
);
}
}
struct
Sass_Options
*
sass_options
;
if
(
isFile
)
{
if
(
isFile
)
{
struct
Sass_File_Context
*
fctx
=
(
struct
Sass_File_Context
*
)
cptr
;
struct
Sass_File_Context
*
fctx
=
(
struct
Sass_File_Context
*
)
cptr
;
struct
Sass_Context
*
ctx
=
sass_file_context_get_context
(
fctx
);
struct
Sass_Context
*
ctx
=
sass_file_context_get_context
(
fctx
);
struct
Sass_Options
*
sass_options
=
sass_context_get_options
(
ctx
);
sass_options
=
sass_context_get_options
(
ctx
);
sass_option_set_output_path
(
sass_options
,
CreateString
(
options
->
Get
(
NanNew
(
"outFile"
))));
sass_option_set_image_path
(
sass_options
,
CreateString
(
options
->
Get
(
NanNew
(
"imagePath"
))));
sass_option_set_output_style
(
sass_options
,
(
Sass_Output_Style
)
options
->
Get
(
NanNew
(
"style"
))
->
Int32Value
());
sass_option_set_source_comments
(
sass_options
,
source_comments
=
options
->
Get
(
NanNew
(
"comments"
))
->
BooleanValue
());
sass_option_set_omit_source_map_url
(
sass_options
,
options
->
Get
(
NanNew
(
"omitSourceMapUrl"
))
->
BooleanValue
());
sass_option_set_source_map_file
(
sass_options
,
CreateString
(
options
->
Get
(
NanNew
(
"sourceMap"
))));
sass_option_set_include_path
(
sass_options
,
CreateString
(
options
->
Get
(
NanNew
(
"paths"
))));
sass_option_set_precision
(
sass_options
,
options
->
Get
(
NanNew
(
"precision"
))
->
Int32Value
());
}
else
{
}
else
{
struct
Sass_Data_Context
*
dctx
=
(
struct
Sass_Data_Context
*
)
cptr
;
struct
Sass_Data_Context
*
dctx
=
(
struct
Sass_Data_Context
*
)
cptr
;
struct
Sass_Context
*
ctx
=
sass_data_context_get_context
(
dctx
);
struct
Sass_Context
*
ctx
=
sass_data_context_get_context
(
dctx
);
s
truct
Sass_Options
*
s
ass_options
=
sass_context_get_options
(
ctx
);
sass_options
=
sass_context_get_options
(
ctx
);
sass_option_set_output_path
(
sass_options
,
CreateString
(
options
->
Get
(
NanNew
(
"outFile"
))));
sass_option_set_is_indented_syntax_src
(
sass_options
,
options
->
Get
(
NanNew
(
"indentedSyntax"
))
->
BooleanValue
());
sass_option_set_is_indented_syntax_src
(
sass_options
,
options
->
Get
(
NanNew
(
"indentedSyntax"
))
->
BooleanValue
());
sass_option_set_image_path
(
sass_options
,
CreateString
(
options
->
Get
(
NanNew
(
"imagePath"
))));
sass_option_set_output_style
(
sass_options
,
(
Sass_Output_Style
)
options
->
Get
(
NanNew
(
"style"
))
->
Int32Value
());
sass_option_set_source_comments
(
sass_options
,
source_comments
=
options
->
Get
(
NanNew
(
"comments"
))
->
BooleanValue
());
sass_option_set_omit_source_map_url
(
sass_options
,
options
->
Get
(
NanNew
(
"omitSourceMapUrl"
))
->
BooleanValue
());
sass_option_set_source_map_file
(
sass_options
,
CreateString
(
options
->
Get
(
NanNew
(
"sourceMap"
))));
sass_option_set_include_path
(
sass_options
,
CreateString
(
options
->
Get
(
NanNew
(
"paths"
))));
sass_option_set_precision
(
sass_options
,
options
->
Get
(
NanNew
(
"precision"
))
->
Int32Value
());
}
}
sass_option_set_output_path
(
sass_options
,
CreateString
(
options
->
Get
(
NanNew
(
"outFile"
))));
sass_option_set_image_path
(
sass_options
,
CreateString
(
options
->
Get
(
NanNew
(
"imagePath"
))));
sass_option_set_output_style
(
sass_options
,
(
Sass_Output_Style
)
options
->
Get
(
NanNew
(
"style"
))
->
Int32Value
());
sass_option_set_source_comments
(
sass_options
,
source_comments
=
options
->
Get
(
NanNew
(
"comments"
))
->
BooleanValue
());
sass_option_set_omit_source_map_url
(
sass_options
,
options
->
Get
(
NanNew
(
"omitSourceMapUrl"
))
->
BooleanValue
());
sass_option_set_source_map_file
(
sass_options
,
CreateString
(
options
->
Get
(
NanNew
(
"sourceMap"
))));
sass_option_set_include_path
(
sass_options
,
CreateString
(
options
->
Get
(
NanNew
(
"paths"
))));
sass_option_set_precision
(
sass_options
,
options
->
Get
(
NanNew
(
"precision"
))
->
Int32Value
());
}
}
void
FillStatsObj
(
Handle
<
Object
>
stats
,
Sass_Context
*
ctx
)
{
void
FillStatsObj
(
Handle
<
Object
>
stats
,
Sass_Context
*
ctx
)
{
...
@@ -149,7 +143,6 @@ NAN_METHOD(Render) {
...
@@ -149,7 +143,6 @@ NAN_METHOD(Render) {
int
status
=
uv_queue_work
(
uv_default_loop
(),
&
ctx_w
->
request
,
compile_it
,
(
uv_after_work_cb
)
MakeCallback
);
int
status
=
uv_queue_work
(
uv_default_loop
(),
&
ctx_w
->
request
,
compile_it
,
(
uv_after_work_cb
)
MakeCallback
);
assert
(
status
==
0
);
assert
(
status
==
0
);
// free(source_string);
NanReturnUndefined
();
NanReturnUndefined
();
}
}
...
@@ -165,7 +158,6 @@ NAN_METHOD(RenderSync) {
...
@@ -165,7 +158,6 @@ NAN_METHOD(RenderSync) {
ExtractOptions
(
options
,
dctx
,
NULL
,
false
);
ExtractOptions
(
options
,
dctx
,
NULL
,
false
);
compile_data
(
dctx
);
compile_data
(
dctx
);
FillStatsObj
(
options
->
Get
(
NanNew
(
"stats"
))
->
ToObject
(),
ctx
);
FillStatsObj
(
options
->
Get
(
NanNew
(
"stats"
))
->
ToObject
(),
ctx
);
// free(source_string);
if
(
sass_context_get_error_status
(
ctx
)
==
0
)
{
if
(
sass_context_get_error_status
(
ctx
)
==
0
)
{
Local
<
String
>
output
=
NanNew
<
String
>
(
sass_context_get_output_string
(
ctx
));
Local
<
String
>
output
=
NanNew
<
String
>
(
sass_context_get_output_string
(
ctx
));
...
@@ -196,7 +188,7 @@ NAN_METHOD(RenderFile) {
...
@@ -196,7 +188,7 @@ NAN_METHOD(RenderFile) {
int
status
=
uv_queue_work
(
uv_default_loop
(),
&
ctx_w
->
request
,
compile_it
,
(
uv_after_work_cb
)
MakeCallback
);
int
status
=
uv_queue_work
(
uv_default_loop
(),
&
ctx_w
->
request
,
compile_it
,
(
uv_after_work_cb
)
MakeCallback
);
assert
(
status
==
0
);
assert
(
status
==
0
);
//
free(input_path);
free
(
input_path
);
NanReturnUndefined
();
NanReturnUndefined
();
}
}
...
@@ -213,7 +205,7 @@ NAN_METHOD(RenderFileSync) {
...
@@ -213,7 +205,7 @@ NAN_METHOD(RenderFileSync) {
compile_file
(
fctx
);
compile_file
(
fctx
);
FillStatsObj
(
options
->
Get
(
NanNew
(
"stats"
))
->
ToObject
(),
ctx
);
FillStatsObj
(
options
->
Get
(
NanNew
(
"stats"
))
->
ToObject
(),
ctx
);
//
free(input_path);
free
(
input_path
);
if
(
sass_context_get_error_status
(
ctx
)
==
0
)
{
if
(
sass_context_get_error_status
(
ctx
)
==
0
)
{
Local
<
String
>
output
=
NanNew
<
String
>
(
sass_context_get_output_string
(
ctx
));
Local
<
String
>
output
=
NanNew
<
String
>
(
sass_context_get_output_string
(
ctx
));
...
...
src/sass_context_wrapper.cpp
View file @
4abc7ddd
...
@@ -26,16 +26,10 @@ extern "C" {
...
@@ -26,16 +26,10 @@ extern "C" {
}
}
void
free_data_context
(
struct
Sass_Data_Context
*
dctx
)
{
void
free_data_context
(
struct
Sass_Data_Context
*
dctx
)
{
// delete[] dctx->source_string;
// delete[] dctx->options.include_paths;
// delete[] dctx->options.image_path;
sass_delete_data_context
(
dctx
);
sass_delete_data_context
(
dctx
);
}
}
void
free_file_context
(
struct
Sass_File_Context
*
fctx
)
{
void
free_file_context
(
struct
Sass_File_Context
*
fctx
)
{
// delete[] fctx->input_path;
// delete[] fctx->options.include_paths;
// delete[] fctx->options.image_path;
sass_delete_file_context
(
fctx
);
sass_delete_file_context
(
fctx
);
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment