Skip to content

Commit 77644ed

Browse files
author
Stas Kobzar
committed
Memory management improved when config parsing.
1 parent 1db95ac commit 77644ed

File tree

12 files changed

+105
-69
lines changed

12 files changed

+105
-69
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ AUTOMAKE = ${SHELL} /home/stas/Dev/amiws/missing automake-1.15
211211
AWK = gawk
212212
CC = gcc
213213
CCDEPMODE = depmode=gcc3
214-
CFLAGS = -g -O2
214+
CFLAGS = -coverage -O0
215215
CPP = gcc -E
216216
CPPFLAGS =
217217
CYGPATH_W = echo

config.log

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ running configure, to aid debugging if configure makes a mistake.
44
It was created by amiws configure 2.0.0, which was
55
generated by GNU Autoconf 2.69. Invocation command line was
66

7-
$ ./configure --with-ssl
7+
$ ./configure --with-ssl CFLAGS=-coverage -O0
88

99
## --------- ##
1010
## Platform. ##
@@ -99,35 +99,35 @@ gcc: fatal error: no input files
9999
compilation terminated.
100100
configure:3129: $? = 1
101101
configure:3149: checking whether the C compiler works
102-
configure:3171: gcc conftest.c >&5
102+
configure:3171: gcc -coverage -O0 conftest.c >&5
103103
configure:3175: $? = 0
104104
configure:3223: result: yes
105105
configure:3226: checking for C compiler default output file name
106106
configure:3228: result: a.out
107107
configure:3234: checking for suffix of executables
108-
configure:3241: gcc -o conftest conftest.c >&5
108+
configure:3241: gcc -o conftest -coverage -O0 conftest.c >&5
109109
configure:3245: $? = 0
110110
configure:3267: result:
111111
configure:3289: checking whether we are cross compiling
112-
configure:3297: gcc -o conftest conftest.c >&5
112+
configure:3297: gcc -o conftest -coverage -O0 conftest.c >&5
113113
configure:3301: $? = 0
114114
configure:3308: ./conftest
115115
configure:3312: $? = 0
116116
configure:3327: result: no
117117
configure:3332: checking for suffix of object files
118-
configure:3354: gcc -c conftest.c >&5
118+
configure:3354: gcc -c -coverage -O0 conftest.c >&5
119119
configure:3358: $? = 0
120120
configure:3379: result: o
121121
configure:3383: checking whether we are using the GNU C compiler
122-
configure:3402: gcc -c conftest.c >&5
122+
configure:3402: gcc -c -coverage -O0 conftest.c >&5
123123
configure:3402: $? = 0
124124
configure:3411: result: yes
125125
configure:3420: checking whether gcc accepts -g
126126
configure:3440: gcc -c -g conftest.c >&5
127127
configure:3440: $? = 0
128128
configure:3481: result: yes
129129
configure:3498: checking for gcc option to accept ISO C89
130-
configure:3561: gcc -c -g -O2 conftest.c >&5
130+
configure:3561: gcc -c -coverage -O0 conftest.c >&5
131131
configure:3561: $? = 0
132132
configure:3574: result: none needed
133133
configure:3599: checking whether gcc understands -c and -o together
@@ -141,19 +141,19 @@ configure:3692: result: GNU
141141
configure:3718: checking dependency style of gcc
142142
configure:3829: result: gcc3
143143
configure:3848: checking for gcc option to accept ISO C99
144-
configure:3997: gcc -c -g -O2 conftest.c >&5
144+
configure:3997: gcc -c -coverage -O0 conftest.c >&5
145145
configure:3997: $? = 0
146146
configure:4010: result: none needed
147147
configure:4118: checking for gcc option to accept ISO Standard C
148148
configure:4129: result: none needed
149149
configure:4146: checking for yaml_parser_initialize in -lyaml
150-
configure:4171: gcc -o conftest -g -O2 conftest.c -lyaml >&5
150+
configure:4171: gcc -o conftest -coverage -O0 conftest.c -lyaml >&5
151151
configure:4171: $? = 0
152152
configure:4180: result: yes
153153
configure:4197: checking for library containing CRYPTO_new_ex_data
154-
configure:4228: gcc -o conftest -g -O2 conftest.c -lyaml >&5
155-
/tmp/stas/cceQIZMu.o: In function `main':
156-
/home/stas/Dev/amiws/conftest.c:23: undefined reference to `CRYPTO_new_ex_data'
154+
configure:4228: gcc -o conftest -coverage -O0 conftest.c -lyaml >&5
155+
/tmp/stas/ccGMXY0q.o: In function `main':
156+
conftest.c:(.text+0x1c): undefined reference to `CRYPTO_new_ex_data'
157157
collect2: error: ld returned 1 exit status
158158
configure:4228: $? = 1
159159
configure: failed program was:
@@ -183,7 +183,7 @@ configure: failed program was:
183183
| ;
184184
| return 0;
185185
| }
186-
configure:4228: gcc -o conftest -g -O2 conftest.c -leay32 -lyaml >&5
186+
configure:4228: gcc -o conftest -coverage -O0 conftest.c -leay32 -lyaml >&5
187187
/usr/bin/ld: cannot find -leay32
188188
collect2: error: ld returned 1 exit status
189189
configure:4228: $? = 1
@@ -214,13 +214,13 @@ configure: failed program was:
214214
| ;
215215
| return 0;
216216
| }
217-
configure:4228: gcc -o conftest -g -O2 conftest.c -lcrypto -lyaml >&5
217+
configure:4228: gcc -o conftest -coverage -O0 conftest.c -lcrypto -lyaml >&5
218218
configure:4228: $? = 0
219219
configure:4245: result: -lcrypto
220220
configure:4257: checking for library containing SSL_library_init
221-
configure:4288: gcc -o conftest -g -O2 conftest.c -lcrypto -lyaml >&5
222-
/tmp/stas/cccJrYjT.o: In function `main':
223-
/home/stas/Dev/amiws/conftest.c:23: undefined reference to `SSL_library_init'
221+
configure:4288: gcc -o conftest -coverage -O0 conftest.c -lcrypto -lyaml >&5
222+
/tmp/stas/ccAClFMJ.o: In function `main':
223+
conftest.c:(.text+0x1c): undefined reference to `SSL_library_init'
224224
collect2: error: ld returned 1 exit status
225225
configure:4288: $? = 1
226226
configure: failed program was:
@@ -250,7 +250,7 @@ configure: failed program was:
250250
| ;
251251
| return 0;
252252
| }
253-
configure:4288: gcc -o conftest -g -O2 conftest.c -lssleay32 -lcrypto -lyaml >&5
253+
configure:4288: gcc -o conftest -coverage -O0 conftest.c -lssleay32 -lcrypto -lyaml >&5
254254
/usr/bin/ld: cannot find -lssleay32
255255
collect2: error: ld returned 1 exit status
256256
configure:4288: $? = 1
@@ -281,7 +281,7 @@ configure: failed program was:
281281
| ;
282282
| return 0;
283283
| }
284-
configure:4288: gcc -o conftest -g -O2 conftest.c -lssl -lcrypto -lyaml >&5
284+
configure:4288: gcc -o conftest -coverage -O0 conftest.c -lssl -lcrypto -lyaml >&5
285285
configure:4288: $? = 0
286286
configure:4305: result: -lssl
287287
configure:4330: checking how to run the C preprocessor
@@ -329,51 +329,51 @@ configure:4521: result: /bin/grep
329329
configure:4526: checking for egrep
330330
configure:4588: result: /bin/grep -E
331331
configure:4593: checking for ANSI C header files
332-
configure:4613: gcc -c -g -O2 conftest.c >&5
332+
configure:4613: gcc -c -coverage -O0 conftest.c >&5
333333
configure:4613: $? = 0
334-
configure:4686: gcc -o conftest -g -O2 conftest.c -lssl -lcrypto -lyaml >&5
334+
configure:4686: gcc -o conftest -coverage -O0 conftest.c -lssl -lcrypto -lyaml >&5
335335
configure:4686: $? = 0
336336
configure:4686: ./conftest
337337
configure:4686: $? = 0
338338
configure:4697: result: yes
339339
configure:4710: checking for sys/types.h
340-
configure:4710: gcc -c -g -O2 conftest.c >&5
340+
configure:4710: gcc -c -coverage -O0 conftest.c >&5
341341
configure:4710: $? = 0
342342
configure:4710: result: yes
343343
configure:4710: checking for sys/stat.h
344-
configure:4710: gcc -c -g -O2 conftest.c >&5
344+
configure:4710: gcc -c -coverage -O0 conftest.c >&5
345345
configure:4710: $? = 0
346346
configure:4710: result: yes
347347
configure:4710: checking for stdlib.h
348-
configure:4710: gcc -c -g -O2 conftest.c >&5
348+
configure:4710: gcc -c -coverage -O0 conftest.c >&5
349349
configure:4710: $? = 0
350350
configure:4710: result: yes
351351
configure:4710: checking for string.h
352-
configure:4710: gcc -c -g -O2 conftest.c >&5
352+
configure:4710: gcc -c -coverage -O0 conftest.c >&5
353353
configure:4710: $? = 0
354354
configure:4710: result: yes
355355
configure:4710: checking for memory.h
356-
configure:4710: gcc -c -g -O2 conftest.c >&5
356+
configure:4710: gcc -c -coverage -O0 conftest.c >&5
357357
configure:4710: $? = 0
358358
configure:4710: result: yes
359359
configure:4710: checking for strings.h
360-
configure:4710: gcc -c -g -O2 conftest.c >&5
360+
configure:4710: gcc -c -coverage -O0 conftest.c >&5
361361
configure:4710: $? = 0
362362
configure:4710: result: yes
363363
configure:4710: checking for inttypes.h
364-
configure:4710: gcc -c -g -O2 conftest.c >&5
364+
configure:4710: gcc -c -coverage -O0 conftest.c >&5
365365
configure:4710: $? = 0
366366
configure:4710: result: yes
367367
configure:4710: checking for stdint.h
368-
configure:4710: gcc -c -g -O2 conftest.c >&5
368+
configure:4710: gcc -c -coverage -O0 conftest.c >&5
369369
configure:4710: $? = 0
370370
configure:4710: result: yes
371371
configure:4710: checking for unistd.h
372-
configure:4710: gcc -c -g -O2 conftest.c >&5
372+
configure:4710: gcc -c -coverage -O0 conftest.c >&5
373373
configure:4710: $? = 0
374374
configure:4710: result: yes
375375
configure:4722: checking syslog.h usability
376-
configure:4722: gcc -c -g -O2 conftest.c >&5
376+
configure:4722: gcc -c -coverage -O0 conftest.c >&5
377377
configure:4722: $? = 0
378378
configure:4722: result: yes
379379
configure:4722: checking syslog.h presence
@@ -386,7 +386,7 @@ configure:4783: checking for ar
386386
configure:4799: found /usr/bin/ar
387387
configure:4810: result: ar
388388
configure:4836: checking the archiver (ar) interface
389-
configure:4852: gcc -c -g -O2 conftest.c >&5
389+
configure:4852: gcc -c -coverage -O0 conftest.c >&5
390390
configure:4852: $? = 0
391391
configure:4854: ar cru libconftest.a conftest.o >&5
392392
ar: `u' modifier ignored since `D' is the default (see `U')
@@ -430,8 +430,8 @@ config.status:1092: executing depfiles commands
430430
ac_cv_c_compiler_gnu=yes
431431
ac_cv_env_CC_set=
432432
ac_cv_env_CC_value=
433-
ac_cv_env_CFLAGS_set=
434-
ac_cv_env_CFLAGS_value=
433+
ac_cv_env_CFLAGS_set=set
434+
ac_cv_env_CFLAGS_value='-coverage -O0'
435435
ac_cv_env_CPPFLAGS_set=
436436
ac_cv_env_CPPFLAGS_value=
437437
ac_cv_env_CPP_set=
@@ -501,7 +501,7 @@ AUTOMAKE='${SHELL} /home/stas/Dev/amiws/missing automake-1.15'
501501
AWK='gawk'
502502
CC='gcc'
503503
CCDEPMODE='depmode=gcc3'
504-
CFLAGS='-g -O2'
504+
CFLAGS='-coverage -O0'
505505
CPP='gcc -E'
506506
CPPFLAGS=''
507507
CYGPATH_W='echo'

config.status

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ $config_commands
427427
428428
Report bugs to <[email protected]>."
429429

430-
ac_cs_config="'--with-ssl'"
430+
ac_cs_config="'--with-ssl' 'CFLAGS=-coverage -O0'"
431431
ac_cs_version="\
432432
amiws config.status 2.0.0
433433
configured by ./configure, generated by GNU Autoconf 2.69,
@@ -519,7 +519,7 @@ if $ac_cs_silent; then
519519
fi
520520

521521
if $ac_cs_recheck; then
522-
set X /bin/bash './configure' '--with-ssl' $ac_configure_extra_args --no-create --no-recursion
522+
set X /bin/bash './configure' '--with-ssl' 'CFLAGS=-coverage -O0' $ac_configure_extra_args --no-create --no-recursion
523523
shift
524524
$as_echo "running CONFIG_SHELL=/bin/bash $*" >&6
525525
CONFIG_SHELL='/bin/bash'
@@ -644,7 +644,7 @@ S["EXEEXT"]=""
644644
S["ac_ct_CC"]="gcc"
645645
S["CPPFLAGS"]=""
646646
S["LDFLAGS"]=""
647-
S["CFLAGS"]="-g -O2"
647+
S["CFLAGS"]="-coverage -O0"
648648
S["CC"]="gcc"
649649
S["RANLIB"]="ranlib"
650650
S["AM_BACKSLASH"]="\\"

doc/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ AUTOMAKE = ${SHELL} /home/stas/Dev/amiws/missing automake-1.15
128128
AWK = gawk
129129
CC = gcc
130130
CCDEPMODE = depmode=gcc3
131-
CFLAGS = -g -O2
131+
CFLAGS = -coverage -O0
132132
CPP = gcc -E
133133
CPPFLAGS =
134134
CYGPATH_W = echo

src/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ AUTOMAKE = ${SHELL} /home/stas/Dev/amiws/missing automake-1.15
217217
AWK = gawk
218218
CC = gcc
219219
CCDEPMODE = depmode=gcc3
220-
CFLAGS = -g -O2
220+
CFLAGS = -coverage -O0
221221
CPP = gcc -E
222222
CPPFLAGS =
223223
CYGPATH_W = echo

src/lib/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ AUTOMAKE = ${SHELL} /home/stas/Dev/amiws/missing automake-1.15
198198
AWK = gawk
199199
CC = gcc
200200
CCDEPMODE = depmode=gcc3
201-
CFLAGS = -g -O2
201+
CFLAGS = -coverage -O0
202202
CPP = gcc -E
203203
CPPFLAGS =
204204
CYGPATH_W = echo

src/lib/amiws.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,15 @@
6262
conf->size = 0; \
6363
conf->head = NULL; \
6464
conf->tail = NULL; \
65-
conf->web_root = DEFAULT_WEB_ROOT; \
65+
conf->web_root = NULL; \
6666
conf->auth_domain = NULL; \
67+
conf->parse_fail = 0; \
68+
conf->syntax_error = 0; \
6769
conf->auth_file = NULL;
6870

6971

7072
/*! Macro to initilize AMI connection. */
71-
#define macro_init_conn(conn) conn = (struct amiws_conn *) calloc(1, sizeof(struct amiws_conn)); \
73+
#define macro_init_conn(conn) conn = (struct amiws_conn *) malloc(sizeof(struct amiws_conn)); \
7274
conn->port = 5038; \
7375
conn->address = NULL; \
7476
conn->name = NULL; \
@@ -98,6 +100,9 @@ struct amiws_config {
98100
char *ssl_cert; /*!< SSL certificate file. */
99101
char *ssl_key; /*!< SSL key file. */
100102
#endif
103+
104+
int parse_fail:1;
105+
int syntax_error:1;
101106
};
102107

103108
/*!

0 commit comments

Comments
 (0)