Skip to content

Commit e2f9962

Browse files
authored
Fix the system-heap measurement patch. (#215)
JSRemoteTest-DCO-1.0-Signed-off-by: Roland Takacs [email protected]
1 parent 8ea0f32 commit e2f9962

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

jstest/resources/patches/iotjs-system-heap.diff

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
diff --git a/src/iotjs.c b/src/iotjs.c
2-
index ef2be53..0720ec6 100644
2+
index 5a93eb7..4a5a8bd 100644
33
--- a/src/iotjs.c
44
+++ b/src/iotjs.c
5-
@@ -246,6 +246,9 @@ terminate:
5+
@@ -242,6 +242,9 @@ terminate:
66
iotjs_terminate(env);
77

88
exit:
@@ -13,7 +13,7 @@ index ef2be53..0720ec6 100644
1313
iotjs_environment_config(env)->debugger->context_reset) {
1414
iotjs_environment_release();
1515
diff --git a/src/iotjs_util.c b/src/iotjs_util.c
16-
index abd7a86..453d597 100644
16+
index abd7a86..cc6b4e3 100644
1717
--- a/src/iotjs_util.c
1818
+++ b/src/iotjs_util.c
1919
@@ -75,12 +75,76 @@ iotjs_string_t iotjs_file_read(const char* path) {
@@ -93,7 +93,7 @@ index abd7a86..453d597 100644
9393
return buffer;
9494
}
9595

96-
@@ -99,16 +163,30 @@ char* iotjs_buffer_allocate_from_number_array(size_t size,
96+
@@ -99,17 +163,31 @@ char* iotjs_buffer_allocate_from_number_array(size_t size,
9797

9898
char* iotjs_buffer_reallocate(char* buffer, size_t size) {
9999
IOTJS_ASSERT(buffer != NULL);
@@ -117,15 +117,16 @@ index abd7a86..453d597 100644
117117

118118

119119
void iotjs_buffer_release(char* buffer) {
120-
+ size_t size;
121-
+ memcpy(&size, (buffer - SIZEOF_MM_ALLOCNODE), sizeof(size_t));
122-
+ mem_stat_free(size - SIZEOF_MM_ALLOCNODE);
123-
+
124120
if (buffer) {
121+
+ size_t size;
122+
+ memcpy(&size, (buffer - SIZEOF_MM_ALLOCNODE), sizeof(size_t));
123+
+ mem_stat_free(size - SIZEOF_MM_ALLOCNODE);
124+
+
125125
free(buffer);
126126
}
127+
}
127128
diff --git a/src/iotjs_util.h b/src/iotjs_util.h
128-
index adccee2..318d6bd 100644
129+
index a891604..786830e 100644
129130
--- a/src/iotjs_util.h
130131
+++ b/src/iotjs_util.h
131132
@@ -23,6 +23,10 @@

0 commit comments

Comments
 (0)