| 63 | } |
| 64 | |
| 65 | void *MSG_GetSpace( msg_t *buf, int length ) { |
| 66 | void *data; |
| 67 | |
| 68 | // round up to the next byte |
| 69 | if ( buf->bit ) { |
| 70 | buf->bit = 0; |
| 71 | buf->cursize++; |
| 72 | } |
| 73 | |
| 74 | if ( buf->cursize + length > buf->maxsize ) { |
| 75 | if ( !buf->allowoverflow ) { |
| 76 | Com_Error (ERR_FATAL, "MSG_GetSpace: overflow without allowoverflow set"); |
| 77 | } |
| 78 | if ( length > buf->maxsize ) { |
| 79 | Com_Error (ERR_FATAL, "MSG_GetSpace: %i is > full buffer size", length); |
| 80 | } |
| 81 | Com_Printf ("MSG_GetSpace: overflow\n"); |
| 82 | MSG_Clear (buf); |
| 83 | buf->overflowed = qtrue; |
| 84 | } |
| 85 | |
| 86 | data = buf->data + buf->cursize; |
| 87 | buf->cursize += length; |
| 88 | |
| 89 | return data; |
| 90 | } |
| 91 | |
| 92 | void MSG_WriteData( msg_t *buf, const void *data, int length ) { |
| 93 | memcpy (MSG_GetSpace(buf,length),data,length); |
no test coverage detected