diff options
author | Badlop <badlop@process-one.net> | 2013-03-14 10:33:02 +0100 |
---|---|---|
committer | Badlop <badlop@process-one.net> | 2013-03-14 10:33:02 +0100 |
commit | 9deb294328bb3f9eb6bd2c0e7cd500732e9b5830 (patch) | |
tree | 7e1066c130250627ee0abab44a135f583a28d07f /src/xml.c | |
parent | list_to_integer/2 only works in OTP R14 and newer (diff) |
Accumulated patch to binarize and indent code
Diffstat (limited to '')
-rw-r--r-- | src/xml.c | 11 |
1 files changed, 6 insertions, 5 deletions
@@ -29,7 +29,7 @@ static int make_element(ErlNifEnv* env, struct buf *rbuf, ERL_NIF_TERM el); static int load(ErlNifEnv* env, void** priv, ERL_NIF_TERM load_info) { - atom_xmlelement = enif_make_atom(env, "xmlelement"); + atom_xmlelement = enif_make_atom(env, "xmlel"); atom_xmlcdata = enif_make_atom(env, "xmlcdata"); return 0; } @@ -57,10 +57,11 @@ inline void resize_buf(ErlNifEnv* env, struct buf *rbuf, int len_to_add) { int new_len = rbuf->len + len_to_add; - if (new_len >= rbuf->limit) { - rbuf->limit = ((new_len / 1024) + 1) * 1024; - rbuf->b = ENIF_REALLOC(rbuf->b, rbuf->limit); - }; + if (new_len > rbuf->limit) { + while (new_len > rbuf->limit) + rbuf->limit *= 2; + rbuf->b = ENIF_REALLOC(rbuf->b, rbuf->limit); + } } static void buf_add_char(ErlNifEnv* env, struct buf *rbuf, unsigned char c) |