Unify coding style

@sjaeckel integrated clang-format with formal coding style. Run his
script and commit changes.

There are pros and cons of this commit.

Mixed coding style is a "broken window". A good single style simplifies
reading and writing code.

On the other hand, this is a big change which will lead to conflicts.
This commit is contained in:
Dmitry Podgorny
2020-01-03 22:02:22 +02:00
parent eef07cef36
commit 562a06425b
62 changed files with 3972 additions and 3746 deletions

View File

@@ -1,5 +1,6 @@
/* test_ctx.c
** libstrophe XMPP client library -- test routines for the library run-time context
** libstrophe XMPP client library -- test routines for the library run-time
*context
**
** Copyright (C) 2005-2009 Collecta, Inc.
**
@@ -21,30 +22,32 @@ static int mem_alloc_called = 0;
static int mem_free_called = 0;
static int mem_realloc_called = 0;
void *my_alloc(const size_t size, void * const userdata)
void *my_alloc(const size_t size, void *const userdata)
{
mem_alloc_called++;
return malloc(size);
}
void my_free(void *p, void * const userdata)
void my_free(void *p, void *const userdata)
{
mem_free_called++;
return free(p);
}
void *my_realloc(void *p, const size_t size, void * const userdata)
void *my_realloc(void *p, const size_t size, void *const userdata)
{
mem_realloc_called++;
return realloc(p, size);
}
void my_logger(void * const userdata, const xmpp_log_level_t level,
const char * const area, const char * const msg)
void my_logger(void *const userdata,
const xmpp_log_level_t level,
const char *const area,
const char *const msg)
{
if (strcmp((char *)userdata, "asdf") == 0 && level == XMPP_LEVEL_DEBUG
&& strcmp(area, "test") == 0 && strcmp(msg, "hello") == 0)
log_called++;
if (strcmp((char *)userdata, "asdf") == 0 && level == XMPP_LEVEL_DEBUG &&
strcmp(area, "test") == 0 && strcmp(msg, "hello") == 0)
log_called++;
}
int main(int argc, char **argv)
@@ -56,7 +59,8 @@ int main(int argc, char **argv)
void *testptr1, *testptr2;
ctx = xmpp_ctx_new(NULL, NULL);
if (ctx == NULL) return 1;
if (ctx == NULL)
return 1;
/* destroy context */
xmpp_ctx_free(ctx);
@@ -75,15 +79,15 @@ int main(int argc, char **argv)
testptr1 = xmpp_alloc(ctx, 1024);
if (testptr1 == NULL) {
xmpp_ctx_free(ctx);
return 1;
xmpp_ctx_free(ctx);
return 1;
}
testptr2 = xmpp_realloc(ctx, testptr1, 2048);
if (testptr2 == NULL) {
xmpp_free(ctx, testptr1);
xmpp_ctx_free(ctx);
return 1;
xmpp_free(ctx, testptr1);
xmpp_ctx_free(ctx);
return 1;
}
xmpp_free(ctx, testptr2);
@@ -92,8 +96,8 @@ int main(int argc, char **argv)
/* check for test failure */
if (!(log_called && mem_alloc_called && mem_realloc_called &&
mem_free_called))
return 1;
mem_free_called))
return 1;
if (mem_alloc_called != mem_free_called)
return 1;