Skip to content

Commit d4fc055

Browse files
committed
fix: make functions static
1 parent 2050ba1 commit d4fc055

File tree

1 file changed

+27
-27
lines changed

1 file changed

+27
-27
lines changed

ext/json_scanner/json_scanner.c

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -93,17 +93,17 @@ typedef struct
9393
size_t yajl_bytes_consumed;
9494
} scan_ctx;
9595

96-
inline size_t scan_ctx_get_bytes_consumed(scan_ctx *ctx)
96+
static inline size_t scan_ctx_get_bytes_consumed(scan_ctx *ctx)
9797
{
9898
return ctx->yajl_bytes_consumed + yajl_get_bytes_consumed(ctx->handle);
9999
}
100100

101-
inline void scan_ctx_save_bytes_consumed(scan_ctx *ctx)
101+
static inline void scan_ctx_save_bytes_consumed(scan_ctx *ctx)
102102
{
103103
ctx->yajl_bytes_consumed += yajl_get_bytes_consumed(ctx->handle);
104104
}
105105

106-
void scan_ctx_debug(scan_ctx *ctx)
106+
static void scan_ctx_debug(scan_ctx *ctx)
107107
{
108108
// actually might have been cleared by GC already, be careful, debug only when in valid state
109109
VALUE points_list_inspect = ctx->points_list == Qundef ? rb_str_new_cstr("undef") : rb_sprintf("%" PRIsVALUE, rb_inspect(ctx->points_list));
@@ -176,7 +176,7 @@ void scan_ctx_debug(scan_ctx *ctx)
176176

177177
// FIXME: This will cause memory leak if ruby_xmalloc raises
178178
// path_ary must be RB_GC_GUARD-ed by the caller
179-
VALUE scan_ctx_init(scan_ctx *ctx, VALUE path_ary, VALUE string_keys)
179+
static VALUE scan_ctx_init(scan_ctx *ctx, VALUE path_ary, VALUE string_keys)
180180
{
181181
int path_ary_len;
182182
paths_t *paths;
@@ -313,7 +313,7 @@ VALUE scan_ctx_init(scan_ctx *ctx, VALUE path_ary, VALUE string_keys)
313313
}
314314

315315
// resets temporary values in the config
316-
void scan_ctx_reset(scan_ctx *ctx, VALUE points_list, VALUE roots_info_list, int with_path, int symbolize_path_keys)
316+
static void scan_ctx_reset(scan_ctx *ctx, VALUE points_list, VALUE roots_info_list, int with_path, int symbolize_path_keys)
317317
{
318318
// TODO: reset matched_depth if implemented
319319
ctx->current_path_len = 0;
@@ -326,7 +326,7 @@ void scan_ctx_reset(scan_ctx *ctx, VALUE points_list, VALUE roots_info_list, int
326326
ctx->symbolize_path_keys = symbolize_path_keys;
327327
}
328328

329-
void scan_ctx_free(scan_ctx *ctx)
329+
static void scan_ctx_free(scan_ctx *ctx)
330330
{
331331
// fprintf(stderr, "scan_ctx_free\n");
332332
if (!ctx)
@@ -343,7 +343,7 @@ void scan_ctx_free(scan_ctx *ctx)
343343
}
344344

345345
// noexcept
346-
inline void increment_arr_index(scan_ctx *sctx)
346+
static inline void increment_arr_index(scan_ctx *sctx)
347347
{
348348
// remember - any value can be root
349349
// TODO: Maybe make current_path_len 1 shorter and get rid of -1; need to change all compares
@@ -364,7 +364,7 @@ typedef enum
364364
} value_type;
365365

366366
// noexcept
367-
VALUE create_point(scan_ctx *sctx, value_type type, size_t length)
367+
static VALUE create_point(scan_ctx *sctx, value_type type, size_t length)
368368
{
369369
VALUE values[3], point;
370370
size_t curr_pos = scan_ctx_get_bytes_consumed(sctx);
@@ -405,7 +405,7 @@ VALUE create_point(scan_ctx *sctx, value_type type, size_t length)
405405
}
406406

407407
// noexcept
408-
VALUE create_path(scan_ctx *sctx)
408+
static VALUE create_path(scan_ctx *sctx)
409409
{
410410
VALUE path = rb_ary_new_capa(sctx->current_path_len);
411411
for (int i = 0; i < sctx->current_path_len; i++)
@@ -431,7 +431,7 @@ VALUE create_path(scan_ctx *sctx)
431431
}
432432

433433
// noexcept
434-
inline void save_root_info(scan_ctx *sctx, VALUE type)
434+
static inline void save_root_info(scan_ctx *sctx, VALUE type)
435435
{
436436
if (sctx->roots_info_list != Qundef && sctx->current_path_len == 0)
437437
{
@@ -440,7 +440,7 @@ inline void save_root_info(scan_ctx *sctx, VALUE type)
440440
}
441441

442442
// noexcept
443-
void save_point(scan_ctx *sctx, value_type type, size_t length)
443+
static void save_point(scan_ctx *sctx, value_type type, size_t length)
444444
{
445445
// TODO: Abort parsing if all paths are matched and no more mathces are possible: only trivial key/index matchers at the current level
446446
// TODO: Don't re-compare already matched prefixes; hard to invalidate, though
@@ -501,7 +501,7 @@ void save_point(scan_ctx *sctx, value_type type, size_t length)
501501
}
502502

503503
// noexcept
504-
int scan_on_null(void *ctx)
504+
static int scan_on_null(void *ctx)
505505
{
506506
scan_ctx *sctx = (scan_ctx *)ctx;
507507
save_root_info(sctx, null_sym);
@@ -513,7 +513,7 @@ int scan_on_null(void *ctx)
513513
}
514514

515515
// noexcept
516-
int scan_on_boolean(void *ctx, int bool_val)
516+
static int scan_on_boolean(void *ctx, int bool_val)
517517
{
518518
scan_ctx *sctx = (scan_ctx *)ctx;
519519
save_root_info(sctx, boolean_sym);
@@ -525,7 +525,7 @@ int scan_on_boolean(void *ctx, int bool_val)
525525
}
526526

527527
// noexcept
528-
int scan_on_number(void *ctx, const char *val, size_t len)
528+
static int scan_on_number(void *ctx, const char *val, size_t len)
529529
{
530530
scan_ctx *sctx = (scan_ctx *)ctx;
531531
save_root_info(sctx, number_sym);
@@ -537,7 +537,7 @@ int scan_on_number(void *ctx, const char *val, size_t len)
537537
}
538538

539539
// noexcept
540-
int scan_on_string(void *ctx, const unsigned char *val, size_t len)
540+
static int scan_on_string(void *ctx, const unsigned char *val, size_t len)
541541
{
542542
scan_ctx *sctx = (scan_ctx *)ctx;
543543
save_root_info(sctx, string_sym);
@@ -549,7 +549,7 @@ int scan_on_string(void *ctx, const unsigned char *val, size_t len)
549549
}
550550

551551
// noexcept
552-
int scan_on_start_object(void *ctx)
552+
static int scan_on_start_object(void *ctx)
553553
{
554554
scan_ctx *sctx = (scan_ctx *)ctx;
555555
// Save in the beginning in case of a partial value
@@ -568,7 +568,7 @@ int scan_on_start_object(void *ctx)
568568
}
569569

570570
// noexcept
571-
int scan_on_key(void *ctx, const unsigned char *key, size_t len)
571+
static int scan_on_key(void *ctx, const unsigned char *key, size_t len)
572572
{
573573
scan_ctx *sctx = (scan_ctx *)ctx;
574574
if (sctx->current_path_len > sctx->max_path_len)
@@ -581,7 +581,7 @@ int scan_on_key(void *ctx, const unsigned char *key, size_t len)
581581
}
582582

583583
// noexcept
584-
int scan_on_end_object(void *ctx)
584+
static int scan_on_end_object(void *ctx)
585585
{
586586
scan_ctx *sctx = (scan_ctx *)ctx;
587587
sctx->current_path_len--;
@@ -591,7 +591,7 @@ int scan_on_end_object(void *ctx)
591591
}
592592

593593
// noexcept
594-
int scan_on_start_array(void *ctx)
594+
static int scan_on_start_array(void *ctx)
595595
{
596596
scan_ctx *sctx = (scan_ctx *)ctx;
597597
// Save in the beginning in case of a partial value
@@ -613,7 +613,7 @@ int scan_on_start_array(void *ctx)
613613
}
614614

615615
// noexcept
616-
int scan_on_end_array(void *ctx)
616+
static int scan_on_end_array(void *ctx)
617617
{
618618
scan_ctx *sctx = (scan_ctx *)ctx;
619619
sctx->current_path_len--;
@@ -622,13 +622,13 @@ int scan_on_end_array(void *ctx)
622622
return true;
623623
}
624624

625-
void config_free(void *data)
625+
static void config_free(void *data)
626626
{
627627
scan_ctx_free((scan_ctx *)data);
628628
ruby_xfree(data);
629629
}
630630

631-
size_t config_size(const void *data)
631+
static size_t config_size(const void *data)
632632
{
633633
// see ObjectSpace.memsize_of
634634
scan_ctx *ctx = (scan_ctx *)data;
@@ -659,7 +659,7 @@ static const rb_data_type_t config_type = {
659659
.flags = RUBY_TYPED_FREE_IMMEDIATELY,
660660
};
661661

662-
VALUE config_alloc(VALUE self)
662+
static VALUE config_alloc(VALUE self)
663663
{
664664
scan_ctx *ctx = ruby_xmalloc(sizeof(scan_ctx));
665665
ctx->paths = NULL;
@@ -671,7 +671,7 @@ VALUE config_alloc(VALUE self)
671671
return TypedData_Wrap_Struct(self, &config_type, ctx);
672672
}
673673

674-
VALUE config_m_initialize(VALUE self, VALUE path_ary)
674+
static VALUE config_m_initialize(VALUE self, VALUE path_ary)
675675
{
676676
scan_ctx *ctx;
677677
VALUE scan_ctx_init_err, string_keys;
@@ -686,7 +686,7 @@ VALUE config_m_initialize(VALUE self, VALUE path_ary)
686686
return self;
687687
}
688688

689-
VALUE config_m_inspect(VALUE self)
689+
static VALUE config_m_inspect(VALUE self)
690690
{
691691
scan_ctx *ctx;
692692
VALUE res;
@@ -738,10 +738,10 @@ static yajl_callbacks scan_callbacks = {
738738

739739
// def scan(json_str, path_arr, opts)
740740
// opts
741-
// with_path: false, verbose_error: false,
741+
// with_path: false, verbose_error: false, symbolize_path_keys: false, with_roots_info: false
742742
// the following opts converted to bool and passed to yajl_config if provided, ignored if not provided
743743
// allow_comments, dont_validate_strings, allow_trailing_garbage, allow_multiple_values, allow_partial_values
744-
VALUE scan(int argc, VALUE *argv, VALUE self)
744+
static VALUE scan(int argc, VALUE *argv, VALUE self)
745745
{
746746
VALUE json_str, path_ary, with_path_flag, kwargs;
747747
VALUE kwargs_values[SCAN_KWARGS_SIZE];

0 commit comments

Comments
 (0)