]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - com_msg.c
PRVM: optimise tempstring creation
[xonotic/darkplaces.git] / com_msg.c
index 80503b62b5307ff3d1ebf44ebf94da2aa02144e4..fe29579ed07c3acc78f4a8fa8e537440b1492935 100644 (file)
--- a/com_msg.c
+++ b/com_msg.c
@@ -346,9 +346,20 @@ char *MSG_ReadString (sizebuf_t *sb, char *string, size_t maxstring)
        while ((c = MSG_ReadByte(sb)) > 0)
                if (l < maxstring - 1)
                        string[l++] = c;
-       string[l] = 0;
+       string[l] = '\0';
        return string;
 }
+size_t MSG_ReadString_len (sizebuf_t *sb, char *string, size_t maxstring)
+{
+       int c;
+       size_t l = 0;
+       // read string into sbfer, but only store as many characters as will fit
+       while ((c = MSG_ReadByte(sb)) > 0)
+               if (l < maxstring - 1)
+                       string[l++] = c;
+       string[l] = '\0';
+       return l;
+}
 
 int MSG_ReadBytes (sizebuf_t *sb, int numbytes, unsigned char *out)
 {