Skip to content

Commit 6fa40a1

Browse files
committed
Clang initial
1 parent 3fbf307 commit 6fa40a1

File tree

5 files changed

+98
-13
lines changed

5 files changed

+98
-13
lines changed

.dockerignore

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Object files
2+
*.o
3+
*.ko
4+
*.obj
5+
*.elf
6+
7+
# Precompiled Headers
8+
*.gch
9+
*.pch
10+
11+
# Libraries
12+
*.lib
13+
*.a
14+
*.la
15+
*.lo
16+
17+
# Shared objects (inc. Windows DLLs)
18+
*.dll
19+
*.so
20+
*.so.*
21+
*.dylib
22+
23+
# Executables
24+
*.exe
25+
*.out
26+
*.app
27+
*.i*86
28+
*.x86_64
29+
*.hex
30+
31+
# Debug files
32+
*.dSYM/
33+
*.su
34+
35+
# Python
36+
.env/
37+
*.pyc
38+
39+
# mkdocs
40+
site/
41+
42+
.vscode/

Dockerfile

+35-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,36 @@
1-
FROM sonarsource/local-travis
1+
FROM ubuntu:xenial
2+
LABEL Description="This image is used to Redis with ReJSON under valgrind" Vendor="Redis Labs" Version="1.0"
23

3-
RUN apt-get -y update && apt-get install -y build-essential cmake python python-pip
4-
RUN pip install redis
4+
RUN apt-get -y update && \
5+
apt-get -y upgrade && \
6+
apt-get -y install \
7+
apt-utils \
8+
build-essential \
9+
wget \
10+
zip \
11+
valgrind
12+
13+
RUN mkdir /build
14+
WORKDIR /build
15+
16+
RUN wget https://github.com/antirez/redis/archive/unstable.zip && \
17+
unzip unstable.zip && \
18+
rm unstable.zip && \
19+
mv redis-unstable redis
20+
21+
WORKDIR /build/redis
22+
RUN make distclean
23+
RUN make valgrind
24+
25+
WORKDIR /build/rejson
26+
COPY ./deps deps/
27+
COPY ./src src/
28+
COPY ./test test/
29+
COPY ./Makefile ./
30+
ENV DEBUG 1
31+
# RUN make all
32+
33+
EXPOSE 6379
34+
WORKDIR /build
35+
CMD ["bash"]
36+
# CMD ["valgrind", "--tool=memcheck", "--leak-check=full", "--track-origins=yes", "--show-reachable=no", "--show-possibly-lost=no", "--suppressions=redis/src/valgrind.sup", "redis/src/redis-server", "--protected-mode", "no", "--loadmodule", "/build/rejson/src/rejson.so"]

Makefile

+6-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,12 @@ test:
55
$(MAKE) -C ./test all
66
.PHONY: test
77

8+
docker:
9+
docker pull ubuntu:latest
10+
docker pull ubuntu:xenial
11+
docker build . -t rejson:latest
12+
813
clean:
914
find ./ -name "*.[oa]" -exec rm {} \; -print
1015
find ./ -name "*.so" -exec rm {} \; -print
11-
find ./ -name "*.out" -exec rm {} \; -print
12-
16+
find ./ -name "*.out" -exec rm {} \; -print

src/json_object.c

+14-7
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,16 @@ inline static int errorCallback(jsonsl_t jsn, jsonsl_error_t err, struct jsonsl_
5252
inline static void pushCallback(jsonsl_t jsn, jsonsl_action_t action, struct jsonsl_state_st *state,
5353
const jsonsl_char_t *at) {
5454
JsonObjectContext *joctx = (JsonObjectContext *)jsn->data;
55-
55+
Node *n = NULL;
5656
// only objects (dictionaries) and lists (arrays) create a container on push
5757
switch (state->type) {
5858
case JSONSL_T_OBJECT:
59-
_pushNode(joctx, NewDictNode(1));
59+
n = NewDictNode(1);
60+
_pushNode(joctx, n);
6061
break;
6162
case JSONSL_T_LIST:
62-
_pushNode(joctx, NewArrayNode(1));
63+
n = NewArrayNode(1);
64+
_pushNode(joctx, n);
6365
break;
6466
default:
6567
break;
@@ -152,16 +154,21 @@ inline static void popCallback(jsonsl_t jsn, jsonsl_action_t action, struct json
152154
// anything that pops needs to be set in its parent, except the root element and keys
153155
if (joctx->nlen > 1 && state->type != JSONSL_T_HKEY) {
154156
NodeType p = joctx->nodes[joctx->nlen - 2]->type;
157+
Node *n = NULL;
155158
switch (p) {
156159
case N_DICT:
157-
Node_DictSetKeyVal(joctx->nodes[joctx->nlen - 1], _popNode(joctx));
160+
n = _popNode(joctx);
161+
Node_DictSetKeyVal(joctx->nodes[joctx->nlen - 1], n);
158162
break;
159163
case N_ARRAY:
160-
Node_ArrayAppend(joctx->nodes[joctx->nlen - 1], _popNode(joctx));
164+
n = _popNode(joctx);
165+
Node_ArrayAppend(joctx->nodes[joctx->nlen - 1], n);
161166
break;
162167
case N_KEYVAL:
163-
joctx->nodes[joctx->nlen - 2]->value.kvval.val = _popNode(joctx);
164-
Node_DictSetKeyVal(joctx->nodes[joctx->nlen - 1], _popNode(joctx));
168+
n = _popNode(joctx);
169+
joctx->nodes[joctx->nlen - 2]->value.kvval.val = n;
170+
n = _popNode(joctx);
171+
Node_DictSetKeyVal(joctx->nodes[joctx->nlen - 1], n);
165172
break;
166173
default:
167174
break;

test/Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ test: test_object test_json_object test_json_validator unittest
3333
build: object json_object json_validator
3434

3535
# Dependency libraries
36-
LIBS = $(RM_INCLUDE_DIR)/librejson.a $(DEPS_DIR)/RedisModuleSDK/rmutil/librmutil.a $(DEPS_DIR)/jsonsl/libjsonsl.a -lm -lrt
36+
LIBS = $(RM_INCLUDE_DIR)/librejson.a $(DEPS_DIR)/RedisModuleSDK/rmutil/librmutil.a $(DEPS_DIR)/jsonsl/libjsonsl.a -lm
3737
# Compile flags for linux / osx
3838
ifeq ($(uname_S),Linux)
3939
LIBS += -lrt

0 commit comments

Comments
 (0)