From 88ff81d9def5efe69cbaf91aa41906177ba7dde9 Mon Sep 17 00:00:00 2001 From: irungentoo Date: Fri, 16 Aug 2013 13:11:09 -0400 Subject: Passed everything through astyle. --- testing/misc_tools.h | 76 +++++++++++++++++++++++++++------------------------- 1 file changed, 39 insertions(+), 37 deletions(-) (limited to 'testing/misc_tools.h') diff --git a/testing/misc_tools.h b/testing/misc_tools.h index b8c90fa6..1379b31a 100644 --- a/testing/misc_tools.h +++ b/testing/misc_tools.h @@ -1,5 +1,5 @@ /* misc_tools.h - * + * * Miscellaneous functions and data structures for doing random things. * * Copyright (C) 2013 Tox project All Rights Reserved. @@ -18,51 +18,51 @@ * * You should have received a copy of the GNU General Public License * along with Tox. If not, see . - * + * */ - + #ifndef MISC_TOOLS_H #define MISC_TOOLS_H #include #include -unsigned char* hex_string_to_bin(char hex_string[]); +unsigned char *hex_string_to_bin(char hex_string[]); /*********************Debugging Macros******************** * wiki.tox.im/index.php/Internal_functions_and_data_structures#Debugging *********************************************************/ #ifdef DEBUG - #include - #include - #include +#include +#include +#include - #define DEBUG_PRINT(str, ...) do { \ +#define DEBUG_PRINT(str, ...) do { \ char msg[1000]; \ sprintf(msg, "%s(): line %d (file %s): %s%%c\n", __FUNCTION__, __LINE__, __FILE__, str); \ fprintf(stderr, msg, __VA_ARGS__); \ } while (0) - #define WARNING(...) do { \ +#define WARNING(...) do { \ fprintf(stderr, "warning in "); \ DEBUG_PRINT(__VA_ARGS__, ' '); \ } while (0) - #define INFO(...) do { \ +#define INFO(...) do { \ DEBUG_PRINT(__VA_ARGS__, ' '); \ } while (0) - - #undef ERROR - #define ERROR(exit_status, ...) do { \ + +#undef ERROR +#define ERROR(exit_status, ...) do { \ fprintf(stderr, "error in "); \ DEBUG_PRINT(__VA_ARGS__, ' '); \ exit(exit_status); \ } while (0) #else - #define WARNING(...) - #define INFO(...) - #undef ERROR - #define ERROR(...) +#define WARNING(...) +#define INFO(...) +#undef ERROR +#define ERROR(...) #endif // DEBUG /************************Linked List*********************** @@ -81,31 +81,31 @@ unsigned char* hex_string_to_bin(char hex_string[]); #define TOX_LIST_GET_VALUE(tmp_name, name_in_parent, parent_type) GET_PARENT(tmp_name, name_in_parent, parent_type) typedef struct tox_list { - struct tox_list *prev, *next; + struct tox_list *prev, *next; } tox_list_t; /* Returns a new tox_list_t. */ -static inline void tox_list_new(tox_list_t* lst) +static inline void tox_list_new(tox_list_t *lst) { - lst->prev = lst->next = lst; + lst->prev = lst->next = lst; } - + /* Inserts a new tox_lst after lst and returns it. */ -static inline void tox_list_add(tox_list_t* lst, tox_list_t* new_lst) +static inline void tox_list_add(tox_list_t *lst, tox_list_t *new_lst) { - tox_list_new(new_lst); + tox_list_new(new_lst); - new_lst->next = lst->next; - new_lst->next->prev = new_lst; + new_lst->next = lst->next; + new_lst->next->prev = new_lst; - lst->next = new_lst; - new_lst->prev = lst; + lst->next = new_lst; + new_lst->prev = lst; } -static inline void tox_list_remove(tox_list_t* lst) +static inline void tox_list_remove(tox_list_t *lst) { - lst->prev->next = lst->next; - lst->next->prev = lst->prev; + lst->prev->next = lst->next; + lst->next->prev = lst->prev; } /****************************Array*************************** @@ -124,7 +124,7 @@ static inline void tox_array_init(struct tox_array *arr) { arr->size = 1; arr->length = 0; - arr->data = malloc(sizeof(void*)); + arr->data = malloc(sizeof(void *)); } static inline void tox_array_delete(struct tox_array *arr) @@ -139,22 +139,24 @@ static inline void tox_array_delete(struct tox_array *arr) static inline void tox_array_shrink_to_fit(struct tox_array *arr, int32_t extra) { arr->size = arr->length + extra; - arr->data = realloc(arr->data, arr->size * sizeof(void*)); + arr->data = realloc(arr->data, arr->size * sizeof(void *)); } static inline void _tox_array_push(struct tox_array *arr, void *new) { - if (arr->length+1 >= arr->size) + if (arr->length + 1 >= arr->size) tox_array_shrink_to_fit(arr, arr->size); + arr->data[arr->length++] = new; } #define tox_array_push(arr, new) _tox_array_push(arr, (void*)new) -static inline void* tox_array_pop(struct tox_array *arr) +static inline void *tox_array_pop(struct tox_array *arr) { - if (arr->length-1 < arr->size/4) - tox_array_shrink_to_fit(arr, arr->length*2); - return arr->data[arr->length--]; + if (arr->length - 1 < arr->size / 4) + tox_array_shrink_to_fit(arr, arr->length * 2); + + return arr->data[arr->length--]; } #endif // MISC_TOOLS_H -- cgit v1.2.3