File tree Expand file tree Collapse file tree 5 files changed +40
-9
lines changed Expand file tree Collapse file tree 5 files changed +40
-9
lines changed Original file line number Diff line number Diff line change @@ -88,7 +88,7 @@ char* source_map_file;
88
88
char * source_map_root;
89
89
```
90
90
``` C
91
- // Custom functions that can be called from sccs code
91
+ // Custom functions that can be called from Sass code
92
92
Sass_C_Function_List c_functions;
93
93
```
94
94
``` C
@@ -168,12 +168,12 @@ struct Sass_Compiler* sass_make_data_compiler (struct Sass_Data_Context* data_ct
168
168
169
169
// Execute the different compilation steps individually
170
170
// Usefull if you only want to query the included files
171
- int sass_compiler_parse(struct Sass_Compiler* compiler);
172
- int sass_compiler_execute(struct Sass_Compiler* compiler);
171
+ int sass_compiler_parse (struct Sass_Compiler* compiler);
172
+ int sass_compiler_execute (struct Sass_Compiler* compiler);
173
173
174
174
// Release all memory allocated with the compiler
175
175
// This does _ not_ include any contexts or options
176
- void sass_delete_compiler(struct Sass_Compiler* compiler);
176
+ void sass_delete_compiler (struct Sass_Compiler* compiler);
177
177
178
178
// Release all memory allocated and also ourself
179
179
void sass_delete_file_context (struct Sass_File_Context* ctx);
Original file line number Diff line number Diff line change @@ -62,6 +62,13 @@ enum Sass_Output_Style {
62
62
SASS_STYLE_TO_SASS
63
63
};
64
64
65
+ // to allocate buffer to be filled
66
+ void * sass_alloc_memory (size_t size );
67
+ // to allocate a buffer from existing string
68
+ char * sass_copy_c_string (const char * str );
69
+ // to free overtaken memory when done
70
+ void sass_free_memory (void * ptr );
71
+
65
72
// Some convenient string helper function
66
73
ADDAPI char * ADDCALL sass_string_quote (const char * str , const char quote_mark );
67
74
ADDAPI char * ADDCALL sass_string_unquote (const char * str );
Original file line number Diff line number Diff line change 11
11
extern " C" {
12
12
using namespace Sass ;
13
13
14
+ // Allocate libsass heap memory
15
+ // Don't forget string termination!
16
+ void * ADDCALL sass_alloc_memory (size_t size)
17
+ {
18
+ void * ptr = malloc (size);
19
+ if (ptr == NULL )
20
+ out_of_memory ();
21
+ return ptr;
22
+ }
23
+
24
+ char * ADDCALL sass_copy_c_string (const char * str)
25
+ {
26
+ size_t len = strlen (str) + 1 ;
27
+ char * cpy = (char *) sass_alloc_memory (len);
28
+ std::memcpy (cpy, str, len);
29
+ return cpy;
30
+ }
31
+
32
+ // Deallocate libsass heap memory
33
+ void ADDCALL sass_free_memory (void * ptr)
34
+ {
35
+ if (ptr) free (ptr);
36
+ }
37
+
14
38
// caller must free the returned memory
15
39
char * ADDCALL sass_string_quote (const char *str, const char quote_mark)
16
40
{
Original file line number Diff line number Diff line change 12
12
13
13
namespace Sass {
14
14
15
- #define out_of_memory () do { \
16
- std::cerr << " Out of memory.\n " ; \
17
- exit (EXIT_FAILURE); \
18
- } while (0 )
19
-
20
15
double round (double val, size_t precision)
21
16
{
22
17
// https://github.com/sass/sass/commit/4e3e1d5684cc29073a507578fc977434ff488c93
Original file line number Diff line number Diff line change 12
12
13
13
namespace Sass {
14
14
15
+ #define out_of_memory () do { \
16
+ std::cerr << " Out of memory.\n " ; \
17
+ exit (EXIT_FAILURE); \
18
+ } while (0 )
19
+
15
20
double round (double val, size_t precision = 0 );
16
21
char * sass_strdup (const char * str);
17
22
double sass_atof (const char * str);
You can’t perform that action at this time.
0 commit comments