aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Schneider <asn@cryptomilk.org>2018-04-18 10:20:55 +0200
committerAndreas Schneider <asn@cryptomilk.org>2018-04-18 10:22:03 +0200
commit6f1f8d2bdbe4fd472408c7981073a0e944e18801 (patch)
tree7336d5e329dd2a84422c583ef0523654e5f6767c
parenta95bc8a0163625ac551d8d73bec08a15aba658ad (diff)
downloadlibssh-6f1f8d2bdbe4fd472408c7981073a0e944e18801.tar.gz
libssh-6f1f8d2bdbe4fd472408c7981073a0e944e18801.tar.xz
libssh-6f1f8d2bdbe4fd472408c7981073a0e944e18801.zip
buffer: Apply coding style to realloc_buffer()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
-rw-r--r--src/buffer.c60
1 files changed, 30 insertions, 30 deletions
diff --git a/src/buffer.c b/src/buffer.c
index 28a345c6..4c59975b 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -127,38 +127,38 @@ void ssh_buffer_set_secure(ssh_buffer buffer){
}
static int realloc_buffer(struct ssh_buffer_struct *buffer, size_t needed) {
- size_t smallest = 1;
- char *new;
+ size_t smallest = 1;
+ char *new;
- buffer_verify(buffer);
+ buffer_verify(buffer);
- /* Find the smallest power of two which is greater or equal to needed */
- while(smallest <= needed) {
- if (smallest == 0) {
- return -1;
- }
- smallest <<= 1;
- }
- needed = smallest;
- if (buffer->secure){
- new = malloc(needed);
- if (new == NULL) {
- return -1;
- }
- memcpy(new, buffer->data,buffer->used);
- explicit_bzero(buffer->data, buffer->used);
- SAFE_FREE(buffer->data);
- } else {
- new = realloc(buffer->data, needed);
- if (new == NULL) {
- buffer->data = NULL;
- return -1;
- }
- }
- buffer->data = new;
- buffer->allocated = needed;
- buffer_verify(buffer);
- return 0;
+ /* Find the smallest power of two which is greater or equal to needed */
+ while(smallest <= needed) {
+ if (smallest == 0) {
+ return -1;
+ }
+ smallest <<= 1;
+ }
+ needed = smallest;
+ if (buffer->secure){
+ new = malloc(needed);
+ if (new == NULL) {
+ return -1;
+ }
+ memcpy(new, buffer->data,buffer->used);
+ explicit_bzero(buffer->data, buffer->used);
+ SAFE_FREE(buffer->data);
+ } else {
+ new = realloc(buffer->data, needed);
+ if (new == NULL) {
+ buffer->data = NULL;
+ return -1;
+ }
+ }
+ buffer->data = new;
+ buffer->allocated = needed;
+ buffer_verify(buffer);
+ return 0;
}
/** @internal