at work
This commit is contained in:
@@ -38,7 +38,7 @@ include_HEADERS = \
|
||||
cstring.h
|
||||
|
||||
if HAVE_VALGRIND
|
||||
VALGRIND_OPT = --tool=memcheck
|
||||
VALGRIND_OPT = --tool=memcheck -s
|
||||
endif
|
||||
|
||||
test: valgrind
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# Makefile.in generated by automake 1.16.1 from Makefile.am.
|
||||
# Makefile.in generated by automake 1.16.3 from Makefile.am.
|
||||
# @configure_input@
|
||||
|
||||
# Copyright (C) 1994-2018 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1994-2020 Free Software Foundation, Inc.
|
||||
|
||||
# This Makefile.in is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
@@ -274,6 +274,7 @@ CC = @CC@
|
||||
CCDEPMODE = @CCDEPMODE@
|
||||
CFLAGS = @CFLAGS@
|
||||
CP = @CP@
|
||||
CPP = @CPP@
|
||||
CPPFLAGS = @CPPFLAGS@
|
||||
CYGPATH_W = @CYGPATH_W@
|
||||
DEFS = @DEFS@
|
||||
@@ -422,7 +423,7 @@ include_HEADERS = \
|
||||
cdynarr.h \
|
||||
cstring.h
|
||||
|
||||
@HAVE_VALGRIND_TRUE@VALGRIND_OPT = --tool=memcheck
|
||||
@HAVE_VALGRIND_TRUE@VALGRIND_OPT = --tool=memcheck -s
|
||||
bin_TESTS = \
|
||||
cstring_test
|
||||
|
||||
|
||||
@@ -174,5 +174,12 @@ int cfparser_parse(cfparser_t * parser) {
|
||||
|
||||
|
||||
void cfparser_destroy(cfparser_t * parser) {
|
||||
free(parser->kvalarr);
|
||||
if (parser == NULL) return;
|
||||
if (parser->kvalarr != NULL) {
|
||||
for (int i = 0; i < parser->kvalsize; i++) {
|
||||
free(parser->kvalarr[i].key);
|
||||
free(parser->kvalarr[i].val);
|
||||
}
|
||||
free(parser->kvalarr);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,15 +10,17 @@
|
||||
|
||||
#include <cstring.h>
|
||||
|
||||
#define INIT_CAPA 1
|
||||
#define INIT_CAPA 128
|
||||
|
||||
/* String container */
|
||||
void* cstring_init(cstring_t* str) {
|
||||
str->data = malloc((INIT_CAPA + 1)*sizeof(char));
|
||||
size_t memsize = (INIT_CAPA + 1)*sizeof(char);
|
||||
str->data = malloc(memsize);
|
||||
if (str->data == NULL) return NULL;
|
||||
memset(str->data, '\0', INIT_CAPA + 1);
|
||||
//memset(str->data, '\0', memsize);
|
||||
str->capa = INIT_CAPA;
|
||||
str->size = 0;
|
||||
str->data[str->size] = '\0';
|
||||
return str->data;
|
||||
}
|
||||
|
||||
@@ -27,14 +29,14 @@ void* cstring_append(cstring_t* str, char* add) {
|
||||
size_t addsize = strlen(add);
|
||||
size_t newsize = str->size + addsize;
|
||||
if (newsize > str->capa) {
|
||||
size_t newcapa = str->capa + addsize;
|
||||
size_t newcapa = (str->capa*24)/18 + addsize*3;
|
||||
char* newstr = realloc(str->data, (newcapa + 1)*sizeof(char));
|
||||
if (newstr == NULL) return NULL;
|
||||
str->data = newstr;
|
||||
str->capa = newcapa;
|
||||
}
|
||||
strcpy(&(str->data[str->size]), add);
|
||||
str->data[newsize + 1] = '\0';
|
||||
memcpy(&(str->data[str->size]), add, addsize);
|
||||
str->data[newsize] = '\0';
|
||||
str->size = newsize;
|
||||
return str->data;
|
||||
}
|
||||
@@ -43,7 +45,6 @@ char* cstring_getref(cstring_t* str) {
|
||||
return str->data;
|
||||
}
|
||||
|
||||
|
||||
void cstring_destroy(cstring_t* str) {
|
||||
if (str == NULL) return;
|
||||
free(str->data);
|
||||
|
||||
185
clib/defines.h
185
clib/defines.h
@@ -1,185 +0,0 @@
|
||||
/* defines.h. Generated from defines.h.in by configure. */
|
||||
/* defines.h.in. Generated from configure.ac by autoheader. */
|
||||
|
||||
/* location of cache dir */
|
||||
#define APP_CACHEDIR "/home/ziggi/Projects/cworker/cache"
|
||||
|
||||
/* location of configuration files for ${PACKAGE} */
|
||||
#define APP_CONFIGDIR "/home/ziggi/Projects/cworker/"
|
||||
|
||||
/* location of database dir */
|
||||
#define APP_DATABASEDIR "/home/ziggi/Projects/cworker/data"
|
||||
|
||||
/* location of libs */
|
||||
#define APP_LIBDIR "/home/ziggi/Projects/cworker/lib"
|
||||
|
||||
/* location of ${PACKAGE} logdir */
|
||||
#define APP_LOGDIR "/home/ziggi/Projects/cworker/log"
|
||||
|
||||
/* location of pid file */
|
||||
#define APP_RUNDIR "/home/ziggi/Projects/cworker/run"
|
||||
|
||||
/* effective user */
|
||||
#define APP_USER "ziggi"
|
||||
|
||||
/* Define to 1 if you have the <arpa/inet.h> header file. */
|
||||
#define HAVE_ARPA_INET_H 1
|
||||
|
||||
/* Define to 1 if you have the `clock_gettime' function. */
|
||||
#define HAVE_CLOCK_GETTIME 1
|
||||
|
||||
/* Define to 1 if you have the declaration of `tzname', and to 0 if you don't.
|
||||
*/
|
||||
/* #undef HAVE_DECL_TZNAME */
|
||||
|
||||
/* Define to 1 if you have the <dlfcn.h> header file. */
|
||||
#define HAVE_DLFCN_H 1
|
||||
|
||||
/* Define to 1 if you have the `dup2' function. */
|
||||
#define HAVE_DUP2 1
|
||||
|
||||
/* Define to 1 if you have the <fcntl.h> header file. */
|
||||
#define HAVE_FCNTL_H 1
|
||||
|
||||
/* Define to 1 if you have the `fork' function. */
|
||||
#define HAVE_FORK 1
|
||||
|
||||
/* Define to 1 if you have the <inttypes.h> header file. */
|
||||
#define HAVE_INTTYPES_H 1
|
||||
|
||||
/* Define to 1 if you have the <limits.h> header file. */
|
||||
#define HAVE_LIMITS_H 1
|
||||
|
||||
/* Define to 1 if you have the <locale.h> header file. */
|
||||
#define HAVE_LOCALE_H 1
|
||||
|
||||
/* Define to 1 if your system has a GNU libc compatible `malloc' function, and
|
||||
to 0 otherwise. */
|
||||
#define HAVE_MALLOC 1
|
||||
|
||||
/* Define to 1 if you have the `memset' function. */
|
||||
#define HAVE_MEMSET 1
|
||||
|
||||
/* Define to 1 if you have the `mkdir' function. */
|
||||
#define HAVE_MKDIR 1
|
||||
|
||||
/* Define to 1 if you have the <netinet/in.h> header file. */
|
||||
#define HAVE_NETINET_IN_H 1
|
||||
|
||||
/* Define to 1 if you have the `setlocale' function. */
|
||||
#define HAVE_SETLOCALE 1
|
||||
|
||||
/* Define to 1 if you have the `socket' function. */
|
||||
#define HAVE_SOCKET 1
|
||||
|
||||
/* Define to 1 if you have the <stdint.h> header file. */
|
||||
#define HAVE_STDINT_H 1
|
||||
|
||||
/* Define to 1 if you have the <stdio.h> header file. */
|
||||
#define HAVE_STDIO_H 1
|
||||
|
||||
/* Define to 1 if you have the <stdlib.h> header file. */
|
||||
#define HAVE_STDLIB_H 1
|
||||
|
||||
/* Define to 1 if you have the <strings.h> header file. */
|
||||
#define HAVE_STRINGS_H 1
|
||||
|
||||
/* Define to 1 if you have the <string.h> header file. */
|
||||
#define HAVE_STRING_H 1
|
||||
|
||||
/* Define to 1 if `tm_zone' is a member of `struct tm'. */
|
||||
#define HAVE_STRUCT_TM_TM_ZONE 1
|
||||
|
||||
/* Define to 1 if you have the <sys/socket.h> header file. */
|
||||
#define HAVE_SYS_SOCKET_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/stat.h> header file. */
|
||||
#define HAVE_SYS_STAT_H 1
|
||||
|
||||
/* Define to 1 if you have the <sys/types.h> header file. */
|
||||
#define HAVE_SYS_TYPES_H 1
|
||||
|
||||
/* Define to 1 if your `struct tm' has `tm_zone'. Deprecated, use
|
||||
`HAVE_STRUCT_TM_TM_ZONE' instead. */
|
||||
#define HAVE_TM_ZONE 1
|
||||
|
||||
/* Define to 1 if you don't have `tm_zone' but do have the external array
|
||||
`tzname'. */
|
||||
/* #undef HAVE_TZNAME */
|
||||
|
||||
/* Define to 1 if you have the <unistd.h> header file. */
|
||||
#define HAVE_UNISTD_H 1
|
||||
|
||||
/* Define to 1 if you have the `vfork' function. */
|
||||
#define HAVE_VFORK 1
|
||||
|
||||
/* Define to 1 if you have the <vfork.h> header file. */
|
||||
/* #undef HAVE_VFORK_H */
|
||||
|
||||
/* Define to 1 if you have the <wchar.h> header file. */
|
||||
#define HAVE_WCHAR_H 1
|
||||
|
||||
/* Define to 1 if you have the <wctype.h> header file. */
|
||||
#define HAVE_WCTYPE_H 1
|
||||
|
||||
/* Define to 1 if `fork' works. */
|
||||
#define HAVE_WORKING_FORK 1
|
||||
|
||||
/* Define to 1 if `vfork' works. */
|
||||
#define HAVE_WORKING_VFORK 1
|
||||
|
||||
/* Define to 1 if the system has the type `_Bool'. */
|
||||
#define HAVE__BOOL 1
|
||||
|
||||
/* Define to the sub-directory where libtool stores uninstalled libraries. */
|
||||
#define LT_OBJDIR ".libs/"
|
||||
|
||||
/* Name of package */
|
||||
#define PACKAGE "cworker"
|
||||
|
||||
/* Define to the address where bug reports for this package should be sent. */
|
||||
#define PACKAGE_BUGREPORT ""
|
||||
|
||||
/* Define to the full name of this package. */
|
||||
#define PACKAGE_NAME "cworker"
|
||||
|
||||
/* Define to the full name and version of this package. */
|
||||
#define PACKAGE_STRING "cworker 0.0.1"
|
||||
|
||||
/* Define to the one symbol short name of this package. */
|
||||
#define PACKAGE_TARNAME "cworker"
|
||||
|
||||
/* Define to the home page for this package. */
|
||||
#define PACKAGE_URL ""
|
||||
|
||||
/* Define to the version of this package. */
|
||||
#define PACKAGE_VERSION "0.0.1"
|
||||
|
||||
/* Define to 1 if all of the C90 standard headers exist (not just the ones
|
||||
required in a freestanding environment). This macro is provided for
|
||||
backward compatibility; new code need not use it. */
|
||||
#define STDC_HEADERS 1
|
||||
|
||||
/* Define to 1 if your <sys/time.h> declares `struct tm'. */
|
||||
/* #undef TM_IN_SYS_TIME */
|
||||
|
||||
/* Version number of package */
|
||||
#define VERSION "0.0.1"
|
||||
|
||||
/* Define to empty if `const' does not conform to ANSI C. */
|
||||
/* #undef const */
|
||||
|
||||
/* Define to rpl_malloc if the replacement function should be used. */
|
||||
/* #undef malloc */
|
||||
|
||||
/* Define to `int' if <sys/types.h> does not define. */
|
||||
/* #undef mode_t */
|
||||
|
||||
/* Define as a signed integer type capable of holding a process identifier. */
|
||||
/* #undef pid_t */
|
||||
|
||||
/* Define to `int' if <sys/types.h> does not define. */
|
||||
/* #undef ssize_t */
|
||||
|
||||
/* Define as `fork' if `vfork' does not work. */
|
||||
/* #undef vfork */
|
||||
@@ -5,6 +5,10 @@
|
||||
*/
|
||||
|
||||
|
||||
#ifdef __linux__
|
||||
#define _GNU_SOURCE
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
@@ -195,8 +199,10 @@ void jblock_destroy(jblock_t* jb) {
|
||||
}
|
||||
free(jb->kvarr[i].key);
|
||||
}
|
||||
|
||||
jb->kvsize = 0;
|
||||
jb->kvcapa = 0;
|
||||
free(jb->kvarr);
|
||||
jb->kvarr = NULL;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user