You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@guacamole.apache.org by mj...@apache.org on 2018/04/02 19:20:50 UTC

[17/23] guacamole-server git commit: GAUCAMOLE-269: Memory effeciency updates.

GAUCAMOLE-269: Memory effeciency updates.


Project: http://git-wip-us.apache.org/repos/asf/guacamole-server/repo
Commit: http://git-wip-us.apache.org/repos/asf/guacamole-server/commit/e16bfd78
Tree: http://git-wip-us.apache.org/repos/asf/guacamole-server/tree/e16bfd78
Diff: http://git-wip-us.apache.org/repos/asf/guacamole-server/diff/e16bfd78

Branch: refs/heads/master
Commit: e16bfd783755fe7cc8019f28f0eb6e997678d8db
Parents: 11136f7
Author: Nick Couchman <vn...@apache.org>
Authored: Sat Mar 24 15:50:11 2018 -0400
Committer: Nick Couchman <vn...@apache.org>
Committed: Sat Mar 24 15:50:11 2018 -0400

----------------------------------------------------------------------
 src/protocols/ssh/ttymode.c | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/guacamole-server/blob/e16bfd78/src/protocols/ssh/ttymode.c
----------------------------------------------------------------------
diff --git a/src/protocols/ssh/ttymode.c b/src/protocols/ssh/ttymode.c
index 4c6091e..4526cc1 100644
--- a/src/protocols/ssh/ttymode.c
+++ b/src/protocols/ssh/ttymode.c
@@ -36,23 +36,22 @@ int guac_ssh_ttymodes_init(char opcode_array[], const int array_size,
     if ((num_opcodes * GUAC_SSH_TTY_OPCODE_SIZE) >= (array_size))
         return 1;
 
+    char *current = opcode_array;
     for (int i = 0; i < num_opcodes; i++) {
-        /* Calculate offset in array */
-        int offset = i * GUAC_SSH_TTY_OPCODE_SIZE;
 
         /* Get the next argument to this function */
-        guac_ssh_ttymode ttymode = va_arg(args, guac_ssh_ttymode);
+        guac_ssh_ttymode* ttymode = va_arg(args, guac_ssh_ttymode*);
 
         /* Place opcode and value in array */
-        opcode_array[offset] = ttymode.opcode;
-        opcode_array[offset + 1] = (ttymode.value >> 24) & 0xFF;
-        opcode_array[offset + 2] = (ttymode.value >> 16) & 0xFF;
-        opcode_array[offset + 3] = (ttymode.value >> 8) & 0xFF;
-        opcode_array[offset + 4] = ttymode.value & 0xFF;
+        *(current++) = ttymode->opcode;
+        *(current++) = (ttymode->value >> 24) & 0xFF;
+        *(current++) = (ttymode->value >> 16) & 0xFF;
+        *(current++) = (ttymode->value >> 8) & 0xFF;
+        *(current++) = ttymode->value & 0xFF;
     }
 
     /* Put the end opcode in the last opcode space */
-    opcode_array[num_opcodes * GUAC_SSH_TTY_OPCODE_SIZE] = GUAC_SSH_TTY_OP_END;
+    *(current) = GUAC_SSH_TTY_OP_END;
 
     return 0;