diff options
author | Alon Zakai <azakai@mozilla.com> | 2010-11-20 11:45:36 -0800 |
---|---|---|
committer | Alon Zakai <azakai@mozilla.com> | 2010-11-20 11:45:36 -0800 |
commit | 4a4472588be087687985695f29a2ca2e02f9648e (patch) | |
tree | d4b490147adee21ea5f2ecf027f4c256c44b910c /src/library.js | |
parent | 6b4d1efe357c8f983b9ec1d0975bb809e37636bc (diff) |
simple realloc implementation
Diffstat (limited to 'src/library.js')
-rw-r--r-- | src/library.js | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/library.js b/src/library.js index 6567ebab..b7c9c157 100644 --- a/src/library.js +++ b/src/library.js @@ -39,6 +39,21 @@ var Library = { throw 'ABORT: ' + code + ', at ' + (new Error().stack); }, + realloc: function(ptr, size) { + // Very simple, inefficient implementation - if you use a real malloc, best to use + // a real realloc with it + if (!size) { + if (ptr) _free(ptr); + return 0; + } + var ret = _malloc(size); + if (ptr) { + _memcpy(ret, ptr, size); // might be some invalid reads + _free(ptr); + } + return ret; + }, + // string.h strspn: function(pstr, pset) { |