Bug 1473441 [wpt PR 11792] - [css-properties-values-api] Require PropertyDescriptor...
[gecko.git] / tools / jprof / strset.cpp
blob623ad3f90575e9c2e7748c3342f5c6edd5c91f9b
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 #include "strset.h"
6 #include <malloc.h>
7 #include <string.h>
9 StrSet::StrSet()
11 strings = 0;
12 numstrings = 0;
15 void StrSet::add(const char* s)
17 if (strings) {
18 strings = (char**) realloc(strings, (numstrings + 1) * sizeof(char*));
19 } else {
20 strings = (char**) malloc(sizeof(char*));
22 strings[numstrings] = strdup(s);
23 numstrings++;
26 int StrSet::contains(const char* s)
28 char** sp = strings;
29 int i = numstrings;
31 while (--i >= 0) {
32 char *ss = *sp++;
33 if (ss[0] == s[0]) {
34 if (strcmp(ss, s) == 0) {
35 return 1;
39 return 0;