-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #199 from lightpanda-io/c_alloc
setCAllocator
- Loading branch information
Showing
19 changed files
with
163 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,10 +3,10 @@ | |
url = [email protected]:lightpanda-io/jsruntime-lib.git | ||
[submodule "vendor/netsurf/libwapcaplet"] | ||
path = vendor/netsurf/libwapcaplet | ||
url = https://source.netsurf-browser.org/libwapcaplet.git | ||
url = [email protected]:lightpanda-io/libwapcaplet.git | ||
[submodule "vendor/netsurf/libparserutils"] | ||
path = vendor/netsurf/libparserutils | ||
url = https://source.netsurf-browser.org/libparserutils.git | ||
url = [email protected]:lightpanda-io/libparserutils.git | ||
[submodule "vendor/netsurf/libdom"] | ||
path = vendor/netsurf/libdom | ||
url = [email protected]:lightpanda-io/libdom.git | ||
|
@@ -15,7 +15,10 @@ | |
url = https://source.netsurf-browser.org/buildsystem.git | ||
[submodule "vendor/netsurf/libhubbub"] | ||
path = vendor/netsurf/libhubbub | ||
url = https://source.netsurf-browser.org/libhubbub.git | ||
url = [email protected]:lightpanda-io/libhubbub.git | ||
[submodule "tests/wpt"] | ||
path = tests/wpt | ||
url = https://github.com/lightpanda-io/wpt | ||
[submodule "vendor/mimalloc"] | ||
path = vendor/mimalloc | ||
url = [email protected]:microsoft/mimalloc.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// This file makes the glue between mimalloc heap allocation and libdom memory | ||
// management. | ||
// We replace the libdom default usage of allocations with mimalloc heap | ||
// allocation to be able to free all memory used at once, like an arena usage. | ||
|
||
const std = @import("std"); | ||
const c = @cImport({ | ||
@cInclude("mimalloc.h"); | ||
}); | ||
|
||
const Error = error{ | ||
HeapNotNull, | ||
HeapNull, | ||
}; | ||
|
||
var heap: ?*c.mi_heap_t = null; | ||
|
||
pub fn create() Error!void { | ||
if (heap != null) return Error.HeapNotNull; | ||
heap = c.mi_heap_new(); | ||
if (heap == null) return Error.HeapNull; | ||
} | ||
|
||
pub fn destroy() void { | ||
if (heap == null) return; | ||
c.mi_heap_destroy(heap.?); | ||
heap = null; | ||
} | ||
|
||
pub export fn m_alloc(size: usize) callconv(.C) ?*anyopaque { | ||
if (heap == null) return null; | ||
return c.mi_heap_malloc(heap.?, size); | ||
} | ||
|
||
pub export fn re_alloc(ptr: ?*anyopaque, size: usize) callconv(.C) ?*anyopaque { | ||
if (heap == null) return null; | ||
return c.mi_heap_realloc(heap.?, ptr, size); | ||
} | ||
|
||
pub export fn c_alloc(nmemb: usize, size: usize) callconv(.C) ?*anyopaque { | ||
if (heap == null) return null; | ||
return c.mi_heap_calloc(heap.?, nmemb, size); | ||
} | ||
|
||
pub export fn str_dup(s: [*c]const u8) callconv(.C) [*c]u8 { | ||
if (heap == null) return null; | ||
return c.mi_heap_strdup(heap.?, s); | ||
} | ||
|
||
pub export fn strn_dup(s: [*c]const u8, size: usize) callconv(.C) [*c]u8 { | ||
if (heap == null) return null; | ||
return c.mi_heap_strndup(heap.?, s, size); | ||
} | ||
|
||
// NOOP, use destroy to clear all the memory allocated at once. | ||
pub export fn f_ree(_: ?*anyopaque) callconv(.C) void { | ||
return; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule libdom
updated
9 files
+28 −0 | bindings/hubbub/utils.h | |
+28 −0 | bindings/xml/utils.h | |
+1 −0 | src/events/event.h | |
+9 −1 | src/events/event_target.c | |
+1 −1 | src/utils/Makefile | |
+1 −0 | src/utils/hashtable.c | |
+18 −0 | src/utils/list.h | |
+32 −0 | src/utils/utils.c | |
+28 −0 | src/utils/utils.h |
Submodule libhubbub
updated
3 files
+1 −1 | src/utils/Makefile | |
+32 −0 | src/utils/utils.c | |
+29 −1 | src/utils/utils.h |
Submodule libparserutils
updated
7 files
+2 −0 | src/charset/codec.c | |
+1 −1 | src/utils/Makefile | |
+2 −0 | src/utils/buffer.c | |
+2 −0 | src/utils/stack.c | |
+32 −0 | src/utils/utils.c | |
+28 −0 | src/utils/utils.h | |
+2 −0 | src/utils/vector.c |
Submodule libwapcaplet
updated
5 files
+5 −0 | include/libwapcaplet/libwapcaplet.h | |
+1 −1 | src/Makefile | |
+30 −0 | src/libwapcaplet.c | |
+32 −0 | src/utils.c | |
+32 −0 | src/utils.h |