aboutsummaryrefslogtreecommitdiff
path: root/src/snippets.js
blob: a93fd0fd33dcb398389ac5244e238438e99f4fa2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
var Snippets = {
  vsnprintf: function(dst, num, src, ptr) {
    var args = [];
    while (HEAP[ptr] != 0) {
      args.push(HEAP[ptr]);
      ptr ++;
    }
    var text = __formatString.apply(null, [src].concat(args));
    for (var i = 0; i < num; i++) {
      HEAP[dst+i] = HEAP[text+i];
      if (HEAP[dst+i] == 0) break;
    }
  },

  atexit: function(func) {
    __ATEXIT__.push(func);
  },

  strspn: function(pstr, pset) {
    var str = String_copy(pstr);
    var set = String_copy(pset);
    var i = 0;
    while (set.indexOf(str[i]) != -1) i++; // Must halt, as 0 is in both
    return i;
  },
};

// Aliases
Snippets.__cxa_atexit = Snippets.atexit;