diff --git a/include/assoc.h b/include/assoc.h index de9a198dccd99aeaed7c7da4da5fdcda7a7a3352..2e0a2cc8c33391fa471e160897d480e72af25463 100644 --- a/include/assoc.h +++ b/include/assoc.h @@ -71,7 +71,7 @@ struct mh_i64ptr_node_t { /* * Map: (char *) => (void *) */ -static inline int lstrcmp(void *a, void *b) +static inline int lstrcmp(const void *a, const void *b) { unsigned int al, bl; @@ -95,7 +95,7 @@ struct mh_lstrptr_node_t { static inline u32 mh_strptr_hash(const mh_node_t *a, mh_hash_arg_t arg) { (void) arg; - void *_k = (a->key); + const void *_k = (a->key); const u32 l = load_varint32(&_k); return (u32) MurmurHash2(_k, l, 13); } diff --git a/include/iobuf.h b/include/iobuf.h index deaf0ffaf21d4d598db7e1a28fa17a88ab23941c..7ee5a07720361caaf8d960666436367bd66ec181 100644 --- a/include/iobuf.h +++ b/include/iobuf.h @@ -154,7 +154,7 @@ obuf_book(struct obuf *obuf, size_t size); /** Append data to the output buffer. */ void -obuf_dup(struct obuf *obuf, void *data, size_t size); +obuf_dup(struct obuf *obuf, const void *data, size_t size); /** * Output buffer savepoint. It's possible to diff --git a/include/pickle.h b/include/pickle.h index 92287cb3acf5ea03f061cdbd68bb92cdcfcf9736..c8dadca92f463d542770d65f8c97d284ee08898a 100644 --- a/include/pickle.h +++ b/include/pickle.h @@ -55,7 +55,7 @@ u32 valid_tuple(struct tbuf *buf, u32 cardinality); size_t varint32_sizeof(u32); static inline u32 -load_varint32_s(void **data, size_t size) +load_varint32_s(const void **data, size_t size) { assert(data != NULL && *data != NULL); const u8 *b = *data; @@ -106,7 +106,7 @@ load_varint32_s(void **data, size_t size) } static inline u32 -load_varint32(void **data) +load_varint32(const void **data) { return load_varint32_s(data, 5); } @@ -117,9 +117,9 @@ load_varint32(void **data) * @returns size of fields data including size of varint data */ inline static size_t -tuple_range_size(void **begin, void *end, size_t count) +tuple_range_size(const void **begin, const void *end, size_t count) { - void *start = *begin; + const void *start = *begin; while (*begin < end && count-- > 0) { size_t len = load_varint32(begin); *begin += len; diff --git a/include/tbuf.h b/include/tbuf.h index 12c6ab1dbc34828be1910a78fb246e2529bda7ba..aea8b10be6f21864a26efe0961dfd12b71fac10e 100644 --- a/include/tbuf.h +++ b/include/tbuf.h @@ -70,7 +70,7 @@ static inline void * tbuf_end(struct tbuf *tbuf) { return tbuf->data + tbuf->size; } static inline size_t -tbuf_unused(struct tbuf *tbuf) { return tbuf->capacity - tbuf->size; } +tbuf_unused(const struct tbuf *tbuf) { return tbuf->capacity - tbuf->size; } struct tbuf *tbuf_clone(struct palloc_pool *pool, const struct tbuf *orig); struct tbuf *tbuf_split(struct tbuf *e, size_t at); @@ -87,7 +87,7 @@ void *tbuf_peek(struct tbuf *b, size_t count); */ void tbuf_ltrim(struct tbuf *b, size_t count); -void tbuf_append_field(struct tbuf *b, void *f); +void tbuf_append_field(struct tbuf *b, const void *f); void tbuf_vprintf(struct tbuf *b, const char *format, va_list ap) __attribute__ ((format(FORMAT_PRINTF, 2, 0))); void tbuf_printf(struct tbuf *b, const char *format, ...) diff --git a/src/box/box_lua.m b/src/box/box_lua.m index a792245eaec40fed0cb3d323f6c4d4b0d1b9160c..ad00c31173cd4be4bf8199afa910e65eae38212f 100644 --- a/src/box/box_lua.m +++ b/src/box/box_lua.m @@ -150,7 +150,7 @@ lbox_tuple_slice(struct lua_State *L) int stop = end - 1; while (field < tuple->data + tuple->bsize) { - size_t len = load_varint32((void **) &field); + size_t len = load_varint32((const void **) &field); if (fieldno >= start) { lua_pushlstring(L, (char *) field, len); if (fieldno == stop) @@ -183,8 +183,8 @@ transform_calculate(struct lua_State *L, struct tuple *tuple, size_t lr[2]) { /* calculate size of the new tuple */ - void *tuple_end = tuple->data + tuple->bsize; - void *tuple_field = tuple->data; + const void *tuple_end = tuple->data + tuple->bsize; + const void *tuple_field = tuple->data; lr[0] = tuple_range_size(&tuple_field, tuple_end, offset); @@ -321,7 +321,7 @@ tuple_find(struct lua_State *L, struct tuple *tuple, size_t offset, return 0; u8 *field = tuple_field(tuple, idx); while (field < tuple->data + tuple->bsize) { - size_t len = load_varint32((void **) &field); + size_t len = load_varint32((const void **) &field); if (len == key_size && (memcmp(field, key, len) == 0)) { lua_pushinteger(L, idx); if (!all) @@ -387,10 +387,10 @@ static int lbox_tuple_unpack(struct lua_State *L) { struct tuple *tuple = lua_checktuple(L, 1); - u8 *field = tuple->data; + const u8 *field = tuple->data; while (field < tuple->data + tuple->bsize) { - size_t len = load_varint32((void **) &field); + size_t len = load_varint32((const void **) &field); lua_pushlstring(L, (char *) field, len); field += len; } @@ -415,7 +415,7 @@ lbox_tuple_index(struct lua_State *L) if (i >= tuple->field_count) luaL_error(L, "%s: index %d is out of bounds (0..%d)", tuplelib_name, i, tuple->field_count-1); - void *field = tuple_field(tuple, i); + const void *field = tuple_field(tuple, i); u32 len = load_varint32(&field); lua_pushlstring(L, field, len); return 1; @@ -474,7 +474,7 @@ lbox_tuple_next(struct lua_State *L) (void)field; assert(field >= tuple->data); if (field < tuple->data + tuple->bsize) { - len = load_varint32((void **) &field); + len = load_varint32((const void **) &field); lua_pushlightuserdata(L, field + len); lua_pushlstring(L, (char *) field, len); return 2; diff --git a/src/box/hash_index.m b/src/box/hash_index.m index 49773839eeffb1d160acb9640233462e8e91fc30..475eb39454484dd576569353f2850fde41215fd6 100644 --- a/src/box/hash_index.m +++ b/src/box/hash_index.m @@ -249,7 +249,7 @@ hash_iterator_lstr_eq(struct iterator *it) /* {{{ Hash32Index ************************************************/ static inline struct mh_i32ptr_node_t -int32_key_to_node(void *key) +int32_key_to_node(const void *key) { u32 key_size = load_varint32(&key); if (key_size != 4) @@ -296,7 +296,7 @@ int32_tuple_to_node(struct tuple *tuple, struct key_def *key_def) return mh_size(int_hash); } -- (struct tuple *) findByKey: (void *) key :(int) part_count +- (struct tuple *) findByKey: (const void *) key :(int) part_count { assert(key_def->is_unique); check_key_parts(key_def, part_count, false); @@ -416,7 +416,7 @@ int32_tuple_to_node(struct tuple *tuple, struct key_def *key_def) /* {{{ Hash64Index ************************************************/ static inline struct mh_i64ptr_node_t -int64_key_to_node(void *key) +int64_key_to_node(const void *key) { u32 key_size = load_varint32(&key); if (key_size != 8) diff --git a/src/box/index.h b/src/box/index.h index dba734b9d4ab5fd7d31705d0c0f94326da528a2e..e83876e75573ed87ec3959b7d0af84b4c71bc550 100644 --- a/src/box/index.h +++ b/src/box/index.h @@ -29,7 +29,6 @@ * SUCH DAMAGE. */ #import "object.h" - #include <stdbool.h> #include <util.h> @@ -203,7 +202,7 @@ enum dup_replace_mode { - (size_t) size; - (struct tuple *) min; - (struct tuple *) max; -- (struct tuple *) findByKey: (void *) key :(int) part_count; +- (struct tuple *) findByKey: (const void *) key :(int) part_count; - (struct tuple *) replace: (struct tuple *) old_tuple :(struct tuple *) new_tuple :(enum dup_replace_mode) mode; @@ -218,7 +217,7 @@ enum dup_replace_mode { @end void -check_key_parts(struct key_def *key_def, int part_count, +check_key_parts(const struct key_def *key_def, int part_count, bool partial_key_allowed); uint32_t diff --git a/src/box/index.m b/src/box/index.m index 5ec5480ccdee389bc1917bead181a0920d4ce4aa..87a83da9fb10964f77f3cce1b7f77095da64dcb5 100644 --- a/src/box/index.m +++ b/src/box/index.m @@ -45,7 +45,7 @@ STRS(iterator_type, ITERATOR_TYPE); /* {{{ Utilities. **********************************************/ void -check_key_parts(struct key_def *key_def, +check_key_parts(const struct key_def *key_def, int part_count, bool partial_key_allowed) { if (part_count > key_def->part_count) diff --git a/src/box/request.m b/src/box/request.m index e8e590f532ae419f027c27e172af1dd6a8a7579e..a77cde95b01321d64834efd86f98ff1c8baa67fd 100644 --- a/src/box/request.m +++ b/src/box/request.m @@ -168,7 +168,7 @@ execute_replace(struct request *request, struct txn *txn) /** Argument of SET operation. */ struct op_set_arg { u32 length; - void *value; + const void *value; }; /** Argument of ADD, AND, XOR, OR operations. */ @@ -182,10 +182,10 @@ struct op_arith_arg { /** Argument of SPLICE. */ struct op_splice_arg { - i32 offset; /** splice position */ - i32 cut_length; /** cut this many bytes. */ - void *paste; /** paste what? */ - i32 paste_length; /** paste this many bytes. */ + i32 offset; /** splice position */ + i32 cut_length; /** cut this many bytes. */ + const void *paste; /** paste what? */ + i32 paste_length; /** paste this many bytes. */ /** Offset of the tail in the old field */ i32 tail_offset; @@ -203,7 +203,7 @@ struct update_field; struct update_op; typedef void (*init_op_func)(struct rope *rope, struct update_op *op); -typedef void (*do_op_func)(union update_op_arg *arg, void *in, void *out); +typedef void (*do_op_func)(union update_op_arg *arg, const void *in, void *out); /** A set of functions and properties to initialize and do an op. */ struct update_op_meta { @@ -232,9 +232,9 @@ struct update_field { /** UPDATE operations against the first field in the range. */ struct op_list ops; /** Points at start of field *data* in the old tuple. */ - void *old; + const void *old; /** End of the old field. */ - void *tail; + const void *tail; /** * Length of the "tail" in the old tuple from end * of old data to the beginning of the field in the @@ -245,7 +245,7 @@ struct update_field { static void update_field_init(struct update_field *field, - void *old, u32 old_len, u32 tail_len) + const void *old, u32 old_len, u32 tail_len) { STAILQ_INIT(&field->ops); field->old = old; @@ -278,14 +278,14 @@ op_adjust_field_no(struct update_op *op, u32 field_max) static void -do_update_op_set(struct op_set_arg *arg, void *in __attribute__((unused)), +do_update_op_set(struct op_set_arg *arg, const void *in __attribute__((unused)), void *out) { memcpy(out, arg->value, arg->length); } static void -do_update_op_add(struct op_arith_arg *arg, void *in, void *out) +do_update_op_add(struct op_arith_arg *arg, const void *in, void *out) { if (arg->val_size == sizeof(i32)) *(i32 *)out = *(i32 *)in + arg->i32_val; @@ -294,7 +294,7 @@ do_update_op_add(struct op_arith_arg *arg, void *in, void *out) } static void -do_update_op_subtract(struct op_arith_arg *arg, void *in, void *out) +do_update_op_subtract(struct op_arith_arg *arg, const void *in, void *out) { if (arg->val_size == sizeof(i32)) *(i32 *)out = *(i32 *)in - arg->i32_val; @@ -303,7 +303,7 @@ do_update_op_subtract(struct op_arith_arg *arg, void *in, void *out) } static void -do_update_op_and(struct op_arith_arg *arg, void *in, void *out) +do_update_op_and(struct op_arith_arg *arg, const void *in, void *out) { if (arg->val_size == sizeof(i32)) *(i32 *)out = *(i32 *)in & arg->i32_val; @@ -312,7 +312,7 @@ do_update_op_and(struct op_arith_arg *arg, void *in, void *out) } static void -do_update_op_xor(struct op_arith_arg *arg, void *in, void *out) +do_update_op_xor(struct op_arith_arg *arg, const void *in, void *out) { if (arg->val_size == sizeof(i32)) *(i32 *)out = *(i32 *)in ^ arg->i32_val; @@ -321,7 +321,7 @@ do_update_op_xor(struct op_arith_arg *arg, void *in, void *out) } static void -do_update_op_or(struct op_arith_arg *arg, void *in, void *out) +do_update_op_or(struct op_arith_arg *arg, const void *in, void *out) { if (arg->val_size == sizeof(i32)) *(i32 *)out = *(i32 *)in | arg->i32_val; @@ -330,7 +330,7 @@ do_update_op_or(struct op_arith_arg *arg, void *in, void *out) } static void -do_update_op_splice(struct op_splice_arg *arg, void *in, void *out) +do_update_op_splice(struct op_splice_arg *arg, const void *in, void *out) { memcpy(out, in, arg->offset); /* copy field head. */ out += arg->offset; @@ -340,8 +340,9 @@ do_update_op_splice(struct op_splice_arg *arg, void *in, void *out) } static void -do_update_op_insert(struct op_set_arg *arg, void *in __attribute__((unused)), - void *out) +do_update_op_insert(struct op_set_arg *arg, + const void *in __attribute__((unused)), + void *out) { memcpy(out, arg->value, arg->length); } @@ -433,13 +434,13 @@ init_update_op_splice(struct rope *rope, struct update_op *op) struct tbuf operands = { .capacity = op->arg.set.length, .size = op->arg.set.length, - .data = op->arg.set.value, + .data = (void*) op->arg.set.value, .pool = NULL }; struct op_splice_arg *arg = &op->arg.splice; /* Read the offset. */ - void *offset_field = read_field(&operands); + const void *offset_field = read_field(&operands); u32 len = load_varint32(&offset_field); if (len != sizeof(i32)) tnt_raise(IllegalParams, :"SPLICE offset"); @@ -456,7 +457,7 @@ init_update_op_splice(struct rope *rope, struct update_op *op) assert(arg->offset >= 0 && arg->offset <= field_len); /* Read the cut length. */ - void *length_field = read_field(&operands); + const void *length_field = read_field(&operands); len = load_varint32(&length_field); if (len != sizeof(i32)) tnt_raise(IllegalParams, :"SPLICE length"); @@ -471,7 +472,7 @@ init_update_op_splice(struct rope *rope, struct update_op *op) } /* Read the paste. */ - void *paste_field = read_field(&operands); + const void *paste_field = read_field(&operands); arg->paste_length = load_varint32(&paste_field); arg->paste = paste_field; @@ -524,8 +525,8 @@ update_field_split(void *data, size_t size __attribute__((unused)), sizeof(struct update_field)); assert(offset > 0 && prev->tail_len > 0); - void *field = prev->tail; - void *end = field + prev->tail_len; + const void *field = prev->tail; + const void *end = field + prev->tail_len; prev->tail_len = tuple_range_size(&field, end, offset - 1); u32 field_len = load_varint32(&field); @@ -551,8 +552,8 @@ update_create_rope(struct update_op *op, struct update_op *op_end, struct update_field *first = palloc(fiber->gc_pool, sizeof(struct update_field)); - void *field = tuple->data; - void *end = tuple->data + tuple->bsize; + const void *field = tuple->data; + const void *end = tuple->data + tuple->bsize; u32 field_len = load_varint32(&field); update_field_init(first, field, field_len, end - field - field_len); @@ -605,9 +606,9 @@ do_update_ops(struct rope *rope, struct tuple *new_tuple) new_data = save_varint32(new_data, field_len); - void *old_field = field->old; + const void *old_field = field->old; void *new_field = (STAILQ_EMPTY(&field->ops) ? - old_field : new_data); + (void*) old_field : new_data); struct update_op *op; STAILQ_FOREACH(op, &field->ops, next) { /* diff --git a/src/box/space.m b/src/box/space.m index a202fd21278c19cf19f2f6f5da59bfca237c2bd8..d3d0f60a0c507985f114a90fb4f377c121d1f4f2 100644 --- a/src/box/space.m +++ b/src/box/space.m @@ -167,10 +167,10 @@ space_validate_tuple(struct space *sp, struct tuple *new_tuple) :"tuple field count must match space cardinality"); /* Sweep through the tuple and check the field sizes. */ - u8 *data = new_tuple->data; + const u8 *data = new_tuple->data; for (int f = 0; f < sp->max_fieldno; ++f) { /* Get the size of the current field and advance. */ - u32 len = load_varint32((void **) &data); + u32 len = load_varint32((const void **) &data); data += len; /* * Check fixed size fields (NUM and NUM64) and diff --git a/src/box/tree_index.m b/src/box/tree_index.m index c105723c49bdd5152516a1e70c7ca3b28425be65..419f2bcf17996983b5f561fd079b6c36a6be7a15 100644 --- a/src/box/tree_index.m +++ b/src/box/tree_index.m @@ -186,7 +186,7 @@ struct fixed_node { */ struct key_data { - u8 *data; + const u8 *data; int part_count; union sparse_part parts[]; }; @@ -306,15 +306,15 @@ fold_with_sparse_parts(struct key_def *key_def, struct tuple *tuple, union spars { assert (tuple->field_count >= key_def->max_fieldno); - u8 *part_data = tuple->data; + const u8 *part_data = tuple->data; memset(parts, 0, sizeof(parts[0]) * key_def->part_count); for (int field = 0; field < key_def->max_fieldno; ++field) { assert(field < tuple->field_count); - u8 *data = part_data; - u32 len = load_varint32((void**) &data); + const u8 *data = part_data; + u32 len = load_varint32((const void**) &data); int part = key_def->cmp_order[field]; if (part != -1) { @@ -347,15 +347,15 @@ fold_with_sparse_parts(struct key_def *key_def, struct tuple *tuple, union spars static void fold_with_key_parts(struct key_def *key_def, struct key_data *key_data) { - u8 *part_data = key_data->data; + const u8 *part_data = key_data->data; union sparse_part* parts = key_data->parts; memset(parts, 0, sizeof(parts[0]) * key_def->part_count); int part_count = MIN(key_def->part_count, key_data->part_count); for (int part = 0; part < part_count; ++part) { - u8 *data = part_data; - u32 len = load_varint32((void**) &data); + const u8 *data = part_data; + u32 len = load_varint32((const void**) &data); if (key_def->parts[part].type == NUM) { if (len != sizeof parts[part].num32) @@ -383,13 +383,13 @@ fold_with_key_parts(struct key_def *key_def, struct key_data *key_data) static u32 fold_with_dense_offset(struct key_def *key_def, struct tuple *tuple) { - u8 *tuple_data = tuple->data; + const u8 *tuple_data = tuple->data; for (int field = 0; field < key_def->max_fieldno; ++field) { assert(field < tuple->field_count); - u8 *data = tuple_data; - u32 len = load_varint32((void**) &data); + const u8 *data = tuple_data; + u32 len = load_varint32((const void**) &data); int part = key_def->cmp_order[field]; if (part != -1) { @@ -408,13 +408,13 @@ fold_with_dense_offset(struct key_def *key_def, struct tuple *tuple) static u32 fold_with_num32_value(struct key_def *key_def, struct tuple *tuple) { - u8 *tuple_data = tuple->data; + const u8 *tuple_data = tuple->data; for (int field = 0; field < key_def->max_fieldno; ++field) { assert(field < tuple->field_count); - u8 *data = tuple_data; - u32 len = load_varint32((void**) &data); + const u8 *data = tuple_data; + u32 len = load_varint32((const void**) &data); int part = key_def->cmp_order[field]; if (part != -1) { @@ -449,14 +449,14 @@ sparse_part_compare(enum field_data_type type, u32 bl = part_b.str.length; if (al == BIG_LENGTH) { ad = data_a + part_a.str.offset; - al = load_varint32((void **) &ad); + al = load_varint32((const void **) &ad); } else { assert(al <= sizeof(part_a.str.data)); ad = part_a.str.data; } if (bl == BIG_LENGTH) { bd = data_b + part_b.str.offset; - bl = load_varint32((void **) &bd); + bl = load_varint32((const void **) &bd); } else { assert(bl <= sizeof(part_b.str.data)); bd = part_b.str.data; @@ -566,8 +566,8 @@ dense_node_compare(struct key_def *key_def, u32 first_field, u8 *ad = tuple_a->data + offset_a; u8 *bd = tuple_b->data + offset_b; for (int i = 1; i < part_count; ++i) { - u32 al = load_varint32((void**) &ad); - u32 bl = load_varint32((void**) &bd); + u32 al = load_varint32((const void**) &ad); + u32 bl = load_varint32((const void**) &bd); ad += al; bd += bl; off_a[i] = ad - tuple_a->data; @@ -605,11 +605,11 @@ linear_node_compare(struct key_def *key_def, assert(first_field + part_count <= tuple_b->field_count); /* Compare key parts. */ - u8 *ad = tuple_a->data + offset_a; - u8 *bd = tuple_b->data + offset_b; + const u8 *ad = tuple_a->data + offset_a; + const u8 *bd = tuple_b->data + offset_b; for (int part = 0; part < part_count; ++part) { - u32 al = load_varint32((void**) &ad); - u32 bl = load_varint32((void**) &bd); + u32 al = load_varint32((const void**) &ad); + u32 bl = load_varint32((const void**) &bd); int r = dense_part_compare(key_def->parts[part].type, ad, al, bd, bl); if (r) { @@ -647,7 +647,7 @@ dense_key_part_compare(enum field_data_type type, u32 al = part_a.str.length; if (al == BIG_LENGTH) { ad = data_a + part_a.str.offset; - al = load_varint32((void **) &ad); + al = load_varint32((const void **) &ad); } else { assert(al <= sizeof(part_a.str.data)); ad = part_a.str.data; @@ -679,9 +679,9 @@ dense_key_node_compare(struct key_def *key_def, /* Find field offsets. */ off[0] = offset; if (part_count > 1) { - u8 *data = tuple->data + offset; + const u8 *data = tuple->data + offset; for (int i = 1; i < part_count; ++i) { - u32 len = load_varint32((void**) &data); + u32 len = load_varint32((const void**) &data); data += len; off[i] = data - tuple->data; } @@ -927,7 +927,7 @@ tree_iterator_gt(struct iterator *iterator) return [self unfold: node]; } -- (struct tuple *) findByKey: (void *) key : (int) part_count +- (struct tuple *) findByKey: (const void *) key : (int) part_count { assert(key_def->is_unique); check_key_parts(key_def, part_count, false); diff --git a/src/box/tuple.m b/src/box/tuple.m index b660b30564d6350a03296db009848e06a91bcb6c..655e1a4a9aea6c07cf0076d7005ead4857b8b395 100644 --- a/src/box/tuple.m +++ b/src/box/tuple.m @@ -78,7 +78,7 @@ tuple_ref(struct tuple *tuple, int count) /** Get the next field from a tuple */ static void * -next_field(void *f) +next_field(const void *f) { u32 size = load_varint32(&f); return (u8 *)f + size; @@ -105,7 +105,7 @@ tuple_field(struct tuple *tuple, size_t i) /** print field to tbuf */ static void -print_field(struct tbuf *buf, void *f) +print_field(struct tbuf *buf, const void *f) { uint32_t size = load_varint32(&f); switch (size) { diff --git a/src/iobuf.m b/src/iobuf.m index d230a0f735587e1872bd3d9d0cd89823335cc83d..f317d572410921087beaf69b5dbddd89442c706c 100644 --- a/src/iobuf.m +++ b/src/iobuf.m @@ -141,7 +141,7 @@ obuf_reset(struct obuf *buf) /** Add data to the output buffer. Copies the data. */ void -obuf_dup(struct obuf *buf, void *data, size_t size) +obuf_dup(struct obuf *buf, const void *data, size_t size) { struct iovec *iov = &buf->iov[buf->pos]; size_t capacity = buf->capacity[buf->pos]; diff --git a/src/memcached-grammar.m b/src/memcached-grammar.m index 283424eb9dcbdf1296af7a826d68513396cc9e7e..e0f341415b7fb920eb45bcd7cfef68ea4e81a4b2 100644 --- a/src/memcached-grammar.m +++ b/src/memcached-grammar.m @@ -416,7 +416,7 @@ tr58: #line 97 "src/memcached-grammar.rl" { struct tbuf *b; - void *value; + const void *value; u32 value_len; key = read_field(keys); @@ -475,7 +475,7 @@ tr62: #line 97 "src/memcached-grammar.rl" { struct tbuf *b; - void *value; + const void *value; u32 value_len; key = read_field(keys); @@ -536,7 +536,7 @@ tr71: #line 97 "src/memcached-grammar.rl" { struct tbuf *b; - void *value; + const void *value; u32 value_len; key = read_field(keys); @@ -709,7 +709,7 @@ tr118: { struct meta *m; struct tbuf *b; - void *field; + const void *field; u32 value_len; u64 value; @@ -774,7 +774,7 @@ tr122: { struct meta *m; struct tbuf *b; - void *field; + const void *field; u32 value_len; u64 value; @@ -841,7 +841,7 @@ tr132: { struct meta *m; struct tbuf *b; - void *field; + const void *field; u32 value_len; u64 value; diff --git a/src/memcached-grammar.rl b/src/memcached-grammar.rl index 46a31b6a3cb847801c8f5a041ba16b7d2cda9c61..cce61f3b22b74b1f4dab435f389c9740c9c04750 100644 --- a/src/memcached-grammar.rl +++ b/src/memcached-grammar.rl @@ -96,7 +96,7 @@ memcached_dispatch(struct ev_io *coio, struct iobuf *iobuf) action append_prepend { struct tbuf *b; - void *value; + const void *value; u32 value_len; key = read_field(keys); @@ -124,7 +124,7 @@ memcached_dispatch(struct ev_io *coio, struct iobuf *iobuf) action incr_decr { struct meta *m; struct tbuf *b; - void *field; + const void *field; u32 value_len; u64 value; diff --git a/src/memcached.m b/src/memcached.m index 2053cadfb705bc94639d22bb354724a5badfbcb1..204c6ab087955f79fd41d0579d6cd1e90f79e7c8 100644 --- a/src/memcached.m +++ b/src/memcached.m @@ -81,7 +81,7 @@ natoq(const char *start, const char *end) } static void -store(void *key, u32 exptime, u32 flags, u32 bytes, const char *data) +store(const void *key, u32 exptime, u32 flags, u32 bytes, const char *data) { u32 box_flags = 0; u32 field_count = 4; @@ -136,7 +136,7 @@ delete(void *key) } static struct tuple * -find(void *key) +find(const void *key) { return [memcached_index findByKey :key :1]; } @@ -156,7 +156,7 @@ expired(struct tuple *tuple) } static bool -is_numeric(void *field, u32 value_len) +is_numeric(const void *field, u32 value_len) { for (int i = 0; i < value_len; i++) if (*((u8 *)field + i) < '0' || '9' < *((u8 *)field + i)) @@ -232,16 +232,16 @@ void memcached_get(struct obuf *out, size_t keys_count, struct tbuf *keys, say_debug("ensuring space for %"PRI_SZ" keys", keys_count); while (keys_count-- > 0) { struct tuple *tuple; - struct meta *m; - void *field; - void *value; - void *suffix; + const struct meta *m; + const void *field; + const void *value; + const void *suffix; u32 key_len; u32 value_len; u32 suffix_len; u32 _l; - void *key = read_field(keys); + const void *key = read_field(keys); tuple = find(key); key_len = load_varint32(&key); diff --git a/src/pickle.m b/src/pickle.m index a4cc72d22486366471e8e68cab760c62aa9f1943..f420ed8852b8ce8ce1924f4d325efa8405b7bf19 100644 --- a/src/pickle.m +++ b/src/pickle.m @@ -97,11 +97,11 @@ read_u(64) u32 read_varint32(struct tbuf *buf) { - void *b = buf->data; + const void *b = buf->data; u32 ret = load_varint32_s(&b, buf->size); size_t read = (b - buf->data); - buf->data = b; + buf->data += read; buf->capacity -= read; buf->size -= read; diff --git a/src/tbuf.m b/src/tbuf.m index c5a46caec6368070e4a01c9f1cc35780b9e7444d..433d81b9a666a90ed935485b4d0efe2df4092e3f 100644 --- a/src/tbuf.m +++ b/src/tbuf.m @@ -161,9 +161,9 @@ tbuf_reset(struct tbuf *b) } void -tbuf_append_field(struct tbuf *b, void *f) +tbuf_append_field(struct tbuf *b, const void *f) { - void *s = f; + const void *s = f; u32 size = load_varint32(&f); void *next = (u8 *)f + size; tbuf_append(b, s, next - s);