diff options
author | LRN <lrn1986@gmail.com> | 2013-12-19 06:00:23 +0000 |
---|---|---|
committer | LRN <lrn1986@gmail.com> | 2013-12-19 06:00:23 +0000 |
commit | e0ca7357cd0bfedc5c29cb731b56279fef8da059 (patch) | |
tree | ecfd47cf59bc00e656b53fd59c58f5038e342d65 /src/regex | |
parent | 92fd84dc7ef98452f848a62677c61a2b80b5835e (diff) | |
download | gnunet-e0ca7357cd0bfedc5c29cb731b56279fef8da059.tar.gz gnunet-e0ca7357cd0bfedc5c29cb731b56279fef8da059.zip |
malloc -> new
Diffstat (limited to 'src/regex')
-rw-r--r-- | src/regex/gnunet-regex-simulation-profiler.c | 2 | ||||
-rw-r--r-- | src/regex/plugin_block_regex.c | 2 | ||||
-rw-r--r-- | src/regex/regex_internal.c | 14 | ||||
-rw-r--r-- | src/regex/regex_internal_dht.c | 8 | ||||
-rw-r--r-- | src/regex/regex_test_lib.c | 8 |
5 files changed, 17 insertions, 17 deletions
diff --git a/src/regex/gnunet-regex-simulation-profiler.c b/src/regex/gnunet-regex-simulation-profiler.c index fdbc918c2..4b3cf5bcd 100644 --- a/src/regex/gnunet-regex-simulation-profiler.c +++ b/src/regex/gnunet-regex-simulation-profiler.c | |||
@@ -179,7 +179,7 @@ create_meter (unsigned int total, char *start_string, int print) | |||
179 | { | 179 | { |
180 | struct ProgressMeter *ret; | 180 | struct ProgressMeter *ret; |
181 | 181 | ||
182 | ret = GNUNET_malloc (sizeof (struct ProgressMeter)); | 182 | ret = GNUNET_new (struct ProgressMeter); |
183 | ret->print = print; | 183 | ret->print = print; |
184 | ret->total = total; | 184 | ret->total = total; |
185 | ret->modnum = total / 4; | 185 | ret->modnum = total / 4; |
diff --git a/src/regex/plugin_block_regex.c b/src/regex/plugin_block_regex.c index 1db1d0d5e..ac9eee07c 100644 --- a/src/regex/plugin_block_regex.c +++ b/src/regex/plugin_block_regex.c | |||
@@ -320,7 +320,7 @@ libgnunet_plugin_block_regex_init (void *cls) | |||
320 | }; | 320 | }; |
321 | struct GNUNET_BLOCK_PluginFunctions *api; | 321 | struct GNUNET_BLOCK_PluginFunctions *api; |
322 | 322 | ||
323 | api = GNUNET_malloc (sizeof (struct GNUNET_BLOCK_PluginFunctions)); | 323 | api = GNUNET_new (struct GNUNET_BLOCK_PluginFunctions); |
324 | api->evaluate = &block_plugin_regex_evaluate; | 324 | api->evaluate = &block_plugin_regex_evaluate; |
325 | api->get_key = &block_plugin_regex_get_key; | 325 | api->get_key = &block_plugin_regex_get_key; |
326 | api->types = types; | 326 | api->types = types; |
diff --git a/src/regex/regex_internal.c b/src/regex/regex_internal.c index 4e0d5acc5..2eeb48b3b 100644 --- a/src/regex/regex_internal.c +++ b/src/regex/regex_internal.c | |||
@@ -132,7 +132,7 @@ state_add_transition (struct REGEX_INTERNAL_Context *ctx, | |||
132 | break; | 132 | break; |
133 | } | 133 | } |
134 | 134 | ||
135 | t = GNUNET_malloc (sizeof (struct REGEX_INTERNAL_Transition)); | 135 | t = GNUNET_new (struct REGEX_INTERNAL_Transition); |
136 | if (NULL != ctx) | 136 | if (NULL != ctx) |
137 | t->id = ctx->transition_id++; | 137 | t->id = ctx->transition_id++; |
138 | if (NULL != label) | 138 | if (NULL != label) |
@@ -1774,7 +1774,7 @@ dfa_state_create (struct REGEX_INTERNAL_Context *ctx, | |||
1774 | struct REGEX_INTERNAL_Transition *ctran; | 1774 | struct REGEX_INTERNAL_Transition *ctran; |
1775 | unsigned int i; | 1775 | unsigned int i; |
1776 | 1776 | ||
1777 | s = GNUNET_malloc (sizeof (struct REGEX_INTERNAL_State)); | 1777 | s = GNUNET_new (struct REGEX_INTERNAL_State); |
1778 | s->id = ctx->state_id++; | 1778 | s->id = ctx->state_id++; |
1779 | s->index = -1; | 1779 | s->index = -1; |
1780 | s->lowlink = -1; | 1780 | s->lowlink = -1; |
@@ -2143,7 +2143,7 @@ dfa_add_multi_strides_helper (void *cls, const unsigned int depth, char *label, | |||
2143 | 2143 | ||
2144 | if (depth == ctx->stride) | 2144 | if (depth == ctx->stride) |
2145 | { | 2145 | { |
2146 | t = GNUNET_malloc (sizeof (struct REGEX_INTERNAL_Transition)); | 2146 | t = GNUNET_new (struct REGEX_INTERNAL_Transition); |
2147 | t->label = GNUNET_strdup (label); | 2147 | t->label = GNUNET_strdup (label); |
2148 | t->to_state = s; | 2148 | t->to_state = s; |
2149 | t->from_state = start; | 2149 | t->from_state = start; |
@@ -2258,7 +2258,7 @@ dfa_compress_paths_helper (struct REGEX_INTERNAL_Automaton *dfa, | |||
2258 | max_len == strlen (label)) || | 2258 | max_len == strlen (label)) || |
2259 | (start == dfa->start && GNUNET_REGEX_INITIAL_BYTES == strlen (label)))) | 2259 | (start == dfa->start && GNUNET_REGEX_INITIAL_BYTES == strlen (label)))) |
2260 | { | 2260 | { |
2261 | t = GNUNET_malloc (sizeof (struct REGEX_INTERNAL_Transition)); | 2261 | t = GNUNET_new (struct REGEX_INTERNAL_Transition); |
2262 | t->label = GNUNET_strdup (label); | 2262 | t->label = GNUNET_strdup (label); |
2263 | t->to_state = cur; | 2263 | t->to_state = cur; |
2264 | t->from_state = start; | 2264 | t->from_state = start; |
@@ -2375,7 +2375,7 @@ nfa_fragment_create (struct REGEX_INTERNAL_State *start, | |||
2375 | { | 2375 | { |
2376 | struct REGEX_INTERNAL_Automaton *n; | 2376 | struct REGEX_INTERNAL_Automaton *n; |
2377 | 2377 | ||
2378 | n = GNUNET_malloc (sizeof (struct REGEX_INTERNAL_Automaton)); | 2378 | n = GNUNET_new (struct REGEX_INTERNAL_Automaton); |
2379 | 2379 | ||
2380 | n->type = NFA; | 2380 | n->type = NFA; |
2381 | n->start = NULL; | 2381 | n->start = NULL; |
@@ -2448,7 +2448,7 @@ nfa_state_create (struct REGEX_INTERNAL_Context *ctx, int accepting) | |||
2448 | { | 2448 | { |
2449 | struct REGEX_INTERNAL_State *s; | 2449 | struct REGEX_INTERNAL_State *s; |
2450 | 2450 | ||
2451 | s = GNUNET_malloc (sizeof (struct REGEX_INTERNAL_State)); | 2451 | s = GNUNET_new (struct REGEX_INTERNAL_State); |
2452 | s->id = ctx->state_id++; | 2452 | s->id = ctx->state_id++; |
2453 | s->accepting = accepting; | 2453 | s->accepting = accepting; |
2454 | s->marked = GNUNET_NO; | 2454 | s->marked = GNUNET_NO; |
@@ -3043,7 +3043,7 @@ REGEX_INTERNAL_construct_dfa (const char *regex, const size_t len, | |||
3043 | return NULL; | 3043 | return NULL; |
3044 | } | 3044 | } |
3045 | 3045 | ||
3046 | dfa = GNUNET_malloc (sizeof (struct REGEX_INTERNAL_Automaton)); | 3046 | dfa = GNUNET_new (struct REGEX_INTERNAL_Automaton); |
3047 | dfa->type = DFA; | 3047 | dfa->type = DFA; |
3048 | dfa->regex = GNUNET_strdup (regex); | 3048 | dfa->regex = GNUNET_strdup (regex); |
3049 | 3049 | ||
diff --git a/src/regex/regex_internal_dht.c b/src/regex/regex_internal_dht.c index e87881902..f7d383406 100644 --- a/src/regex/regex_internal_dht.c +++ b/src/regex/regex_internal_dht.c | |||
@@ -187,7 +187,7 @@ REGEX_INTERNAL_announce (struct GNUNET_DHT_Handle *dht, | |||
187 | struct REGEX_INTERNAL_Announcement *h; | 187 | struct REGEX_INTERNAL_Announcement *h; |
188 | 188 | ||
189 | GNUNET_assert (NULL != dht); | 189 | GNUNET_assert (NULL != dht); |
190 | h = GNUNET_malloc (sizeof (struct REGEX_INTERNAL_Announcement)); | 190 | h = GNUNET_new (struct REGEX_INTERNAL_Announcement); |
191 | h->regex = regex; | 191 | h->regex = regex; |
192 | h->dht = dht; | 192 | h->dht = dht; |
193 | h->stats = stats; | 193 | h->stats = stats; |
@@ -614,7 +614,7 @@ regex_next_edge (const struct RegexBlock *block, | |||
614 | } | 614 | } |
615 | 615 | ||
616 | hash = &ctx->hash; | 616 | hash = &ctx->hash; |
617 | new_ctx = GNUNET_malloc (sizeof (struct RegexSearchContext)); | 617 | new_ctx = GNUNET_new (struct RegexSearchContext); |
618 | new_ctx->info = info; | 618 | new_ctx->info = info; |
619 | new_ctx->position = ctx->position + ctx->longest_match; | 619 | new_ctx->position = ctx->position + ctx->longest_match; |
620 | GNUNET_array_append (info->contexts, info->n_contexts, new_ctx); | 620 | GNUNET_array_append (info->contexts, info->n_contexts, new_ctx); |
@@ -693,7 +693,7 @@ REGEX_INTERNAL_search (struct GNUNET_DHT_Handle *dht, | |||
693 | LOG (GNUNET_ERROR_TYPE_INFO, "REGEX_INTERNAL_search: %s\n", string); | 693 | LOG (GNUNET_ERROR_TYPE_INFO, "REGEX_INTERNAL_search: %s\n", string); |
694 | GNUNET_assert (NULL != dht); | 694 | GNUNET_assert (NULL != dht); |
695 | GNUNET_assert (NULL != callback); | 695 | GNUNET_assert (NULL != callback); |
696 | h = GNUNET_malloc (sizeof (struct REGEX_INTERNAL_Search)); | 696 | h = GNUNET_new (struct REGEX_INTERNAL_Search); |
697 | h->dht = dht; | 697 | h->dht = dht; |
698 | h->description = GNUNET_strdup (string); | 698 | h->description = GNUNET_strdup (string); |
699 | h->callback = callback; | 699 | h->callback = callback; |
@@ -708,7 +708,7 @@ REGEX_INTERNAL_search (struct GNUNET_DHT_Handle *dht, | |||
708 | LOG (GNUNET_ERROR_TYPE_INFO, | 708 | LOG (GNUNET_ERROR_TYPE_INFO, |
709 | " initial key for %s: %s (%.*s)\n", | 709 | " initial key for %s: %s (%.*s)\n", |
710 | string, GNUNET_h2s (&key), size, string); | 710 | string, GNUNET_h2s (&key), size, string); |
711 | ctx = GNUNET_malloc (sizeof (struct RegexSearchContext)); | 711 | ctx = GNUNET_new (struct RegexSearchContext); |
712 | ctx->position = size; | 712 | ctx->position = size; |
713 | ctx->info = h; | 713 | ctx->info = h; |
714 | GNUNET_array_append (h->contexts, h->n_contexts, ctx); | 714 | GNUNET_array_append (h->contexts, h->n_contexts, ctx); |
diff --git a/src/regex/regex_test_lib.c b/src/regex/regex_test_lib.c index 09d608e65..2f3abdc65 100644 --- a/src/regex/regex_test_lib.c +++ b/src/regex/regex_test_lib.c | |||
@@ -245,7 +245,7 @@ regex_add (struct RegexCombineCtx *ctx, const char *regex) | |||
245 | len = strlen (p->s); | 245 | len = strlen (p->s); |
246 | if (prefix_l < len) /* only partial match, split existing state */ | 246 | if (prefix_l < len) /* only partial match, split existing state */ |
247 | { | 247 | { |
248 | newctx = GNUNET_malloc (sizeof (struct RegexCombineCtx)); | 248 | newctx = GNUNET_new (struct RegexCombineCtx); |
249 | newctx->head = p->head; | 249 | newctx->head = p->head; |
250 | newctx->tail = p->tail; | 250 | newctx->tail = p->tail; |
251 | newctx->s = GNUNET_malloc(len - prefix_l + 1); | 251 | newctx->s = GNUNET_malloc(len - prefix_l + 1); |
@@ -262,14 +262,14 @@ regex_add (struct RegexCombineCtx *ctx, const char *regex) | |||
262 | if (NULL == ctx->head && NULL != ctx->s) | 262 | if (NULL == ctx->head && NULL != ctx->s) |
263 | { | 263 | { |
264 | /* this was the end before, add empty string */ | 264 | /* this was the end before, add empty string */ |
265 | newctx = GNUNET_malloc (sizeof (struct RegexCombineCtx)); | 265 | newctx = GNUNET_new (struct RegexCombineCtx); |
266 | newctx->s = GNUNET_strdup (""); | 266 | newctx->s = GNUNET_strdup (""); |
267 | GNUNET_CONTAINER_DLL_insert (ctx->head, ctx->tail, newctx); | 267 | GNUNET_CONTAINER_DLL_insert (ctx->head, ctx->tail, newctx); |
268 | } | 268 | } |
269 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " no match\n"); | 269 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " no match\n"); |
270 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " new state %s\n", regex); | 270 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " new state %s\n", regex); |
271 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " under %s\n", ctx->s); | 271 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, " under %s\n", ctx->s); |
272 | newctx = GNUNET_malloc (sizeof (struct RegexCombineCtx)); | 272 | newctx = GNUNET_new (struct RegexCombineCtx); |
273 | newctx->s = GNUNET_strdup (regex); | 273 | newctx->s = GNUNET_strdup (regex); |
274 | GNUNET_CONTAINER_DLL_insert (ctx->head, ctx->tail, newctx); | 274 | GNUNET_CONTAINER_DLL_insert (ctx->head, ctx->tail, newctx); |
275 | } | 275 | } |
@@ -312,7 +312,7 @@ REGEX_TEST_combine (char * const regexes[]) | |||
312 | const char *current; | 312 | const char *current; |
313 | struct RegexCombineCtx *ctx; | 313 | struct RegexCombineCtx *ctx; |
314 | 314 | ||
315 | ctx = GNUNET_malloc (sizeof (struct RegexCombineCtx)); | 315 | ctx = GNUNET_new (struct RegexCombineCtx); |
316 | for (i = 0; regexes[i]; i++) | 316 | for (i = 0; regexes[i]; i++) |
317 | { | 317 | { |
318 | current = regexes[i]; | 318 | current = regexes[i]; |