1 : /*
2 : * Copyright (c) 2012 The Native Client Authors. All rights reserved.
3 : * Use of this source code is governed by a BSD-style license that can be
4 : * found in the LICENSE file.
5 : */
6 :
7 : #include <string.h>
8 :
9 : #include "native_client/src/trusted/interval_multiset/nacl_interval_list.h"
10 : #include "native_client/src/trusted/interval_multiset/nacl_interval_list_intern.h"
11 : #include "native_client/src/trusted/interval_multiset/nacl_interval_multiset.h"
12 : #include "native_client/src/trusted/interval_multiset/nacl_interval_range_tree.h"
13 : #include "native_client/src/trusted/interval_multiset/nacl_interval_range_tree_intern.h"
14 :
15 1 : struct NaClIntervalMultiset *NaClIntervalMultisetFactory(char const *kind) {
16 1 : struct NaClIntervalMultiset *widget = NULL;
17 :
18 : #define MAKE(tag) do { \
19 : if (0 == strcmp(#tag, kind)) { \
20 : widget = (struct NaClIntervalMultiset *) malloc( \
21 : sizeof(struct tag)); \
22 : if (NULL != widget && !tag ## Ctor((struct tag *) widget)) { \
23 : free(widget); \
24 : widget = NULL; \
25 : } \
26 : return widget; \
27 : } \
28 : } while (0)
29 :
30 1 : MAKE(NaClIntervalListMultiset);
31 1 : MAKE(NaClIntervalRangeTree);
32 :
33 0 : return NULL;
34 1 : }
|