From 2b9724f6a0ded0d4644c12d132580931787f135b Mon Sep 17 00:00:00 2001 From: Oleg Grenrus Date: Thu, 28 Aug 2014 01:14:59 -0400 Subject: [PATCH] Cleanup whitespace --- hash.h | 6 ++--- hash_si.c | 60 +++++++++++++++++++++++++------------------------- igbinary.h | 4 ++-- php_igbinary.h | 4 ++-- 4 files changed, 37 insertions(+), 37 deletions(-) diff --git a/hash.h b/hash.h index 94bd87d..3fb57ec 100644 --- a/hash.h +++ b/hash.h @@ -1,10 +1,10 @@ /* +----------------------------------------------------------------------+ | See COPYING file for further copyright information | - +----------------------------------------------------------------------+ + +----------------------------------------------------------------------+ | Author: Oleg Grenrus | | See CREDITS for contributors | - +----------------------------------------------------------------------+ + +----------------------------------------------------------------------+ */ #ifndef HASH_H @@ -85,7 +85,7 @@ int hash_si_find (struct hash_si *h, const char *key, size_t key_len, uint32_t * int hash_si_remove (struct hash_si *h, const char *key, size_t key_len, uint32_t * value); /** Travarses hash_si. - * Calls traverse_function on every item. Traverse function should not modify hash + * Calls traverse_function on every item. Traverse function should not modify hash * @param h Pointer to hash_si struct. * @param traverse_function Function to call on every item of hash_si. */ diff --git a/hash_si.c b/hash_si.c index 5005c1c..07a4c21 100644 --- a/hash_si.c +++ b/hash_si.c @@ -1,10 +1,10 @@ /* +----------------------------------------------------------------------+ | See COPYING file for further copyright information | - +----------------------------------------------------------------------+ + +----------------------------------------------------------------------+ | Author: Oleg Grenrus | | See CREDITS for contributors | - +----------------------------------------------------------------------+ + +----------------------------------------------------------------------+ */ #ifdef PHP_WIN32 @@ -46,14 +46,14 @@ int hash_si_init(struct hash_si *h, size_t size) { } memset(h->data, 0, sizeof(struct hash_si_pair) * size); - + return 0; } /* }}} */ /* {{{ hash_si_deinit */ void hash_si_deinit(struct hash_si *h) { size_t i; - + for (i = 0; i < h->size; i++) { if (h->data[i].key != NULL) { free(h->data[i].key); @@ -76,20 +76,20 @@ void hash_si_deinit(struct hash_si *h) { inline static size_t _hash_si_find(struct hash_si *h, const char *key, size_t key_len) { uint32_t hv; size_t size; - + assert(h != NULL); - + size = h->size; hv = zend_inline_hash_func(key, key_len) & (h->size-1); - + while (size > 0 && h->data[hv].key != NULL && - (h->data[hv].key_len != key_len || memcmp(h->data[hv].key, key, key_len) != 0)) { + (h->data[hv].key_len != key_len || memcmp(h->data[hv].key, key, key_len) != 0)) { /* linear prob */ hv = (hv + 1) & (h->size-1); size--; } - + return hv; } /* }}} */ @@ -97,9 +97,9 @@ inline static size_t _hash_si_find(struct hash_si *h, const char *key, size_t ke int hash_si_remove(struct hash_si *h, const char *key, size_t key_len, uint32_t *value) { uint32_t hv; uint32_t j, k; - + assert(h != NULL); - + hv = _hash_si_find(h, key, key_len); /* dont exists */ @@ -108,26 +108,26 @@ int hash_si_remove(struct hash_si *h, const char *key, size_t key_len, uint32_t } h->used--; - + free(h->data[hv].key); - if (value != NULL) + if (value != NULL) *value = h->data[hv].value; - j = (hv + 1) & (h->size-1); + j = (hv + 1) & (h->size-1); while (h->data[j].key != NULL) { k = zend_inline_hash_func(h->data[j].key, strlen(h->data[j].key)) & (h->size-1); if ((j > hv && (k <= hv || k > j)) || (j < hv && (k <= hv && k > j))) { h->data[hv].key = h->data[j].key; h->data[hv].key_len = h->data[j].key_len; h->data[hv].value = h->data[j].value; - + hv = j; } - j = (j + 1) & (h->size-1); + j = (j + 1) & (h->size-1); } h->data[hv].key = NULL; - + return 0; /* @@ -140,7 +140,7 @@ int hash_si_remove(struct hash_si *h, const char *key, size_t key_len, uint32_t * (j < i and (k <= i and k > j)) (note 2) * slot[i] := slot[j] * i := j - * mark slot[i] as unoccupied + * mark slot[i] as unoccupied * * For all records in a cluster, there must be no vacant slots between their natural * hash position and their current position (else lookups will terminate before finding @@ -166,11 +166,11 @@ inline static void hash_si_rehash(struct hash_si *h) { uint32_t hv; size_t i; struct hash_si newh; - + assert(h != NULL); - + hash_si_init(&newh, h->size * 2); - + for (i = 0; i < h->size; i++) { if (h->data[i].key != NULL) { hv = _hash_si_find(&newh, h->data[i].key, h->data[i].key_len); @@ -178,8 +178,8 @@ inline static void hash_si_rehash(struct hash_si *h) { newh.data[hv].key_len = h->data[i].key_len; newh.data[hv].value = h->data[i].value; } - } - + } + free(h->data); h->data = newh.data; h->size *= 2; @@ -192,9 +192,9 @@ int hash_si_insert(struct hash_si *h, const char *key, size_t key_len, uint32_t if (h->size / 4 * 3 < h->used + 1) { hash_si_rehash(h); } - + hv = _hash_si_find(h, key, key_len); - + if (h->data[hv].key == NULL) { h->data[hv].key = (char *) malloc(key_len + 1); if (h->data[hv].key == NULL) { @@ -208,9 +208,9 @@ int hash_si_insert(struct hash_si *h, const char *key, size_t key_len, uint32_t } else { return 2; } - + h->data[hv].value = value; - + return 0; } /* }}} */ @@ -219,9 +219,9 @@ int hash_si_find(struct hash_si *h, const char *key, size_t key_len, uint32_t *v uint32_t hv; assert(h != NULL); - + hv = _hash_si_find(h, key, key_len); - + if (h->data[hv].key == NULL) { return 1; } else { @@ -235,7 +235,7 @@ void hash_si_traverse(struct hash_si *h, int (*traverse_function) (const char *k size_t i; assert(h != NULL && traverse_function != NULL); - + for (i = 0; i < h->size; i++) { if (h->data[i].key != NULL && traverse_function(h->data[i].key, h->data[i].key_len, h->data[i].value) != 1) { return; diff --git a/igbinary.h b/igbinary.h index b9786c8..0e3abc6 100644 --- a/igbinary.h +++ b/igbinary.h @@ -1,10 +1,10 @@ /* +----------------------------------------------------------------------+ | See COPYING file for further copyright information | - +----------------------------------------------------------------------+ + +----------------------------------------------------------------------+ | Author: Oleg Grenrus | | See CREDITS for contributors | - +----------------------------------------------------------------------+ + +----------------------------------------------------------------------+ */ #ifndef IGBINARY_H diff --git a/php_igbinary.h b/php_igbinary.h index 32d3cba..957bebb 100644 --- a/php_igbinary.h +++ b/php_igbinary.h @@ -1,10 +1,10 @@ /* +----------------------------------------------------------------------+ | See COPYING file for further copyright information | - +----------------------------------------------------------------------+ + +----------------------------------------------------------------------+ | Author: Oleg Grenrus | | See CREDITS for contributors | - +----------------------------------------------------------------------+ + +----------------------------------------------------------------------+ */ #ifndef PHP_IGBINARY_H