write n bytes from ptr into block returns actual number of bytes written if buffer isn't large enough only a portion of the bytes will be written
| 67 | // returns actual number of bytes written |
| 68 | // if buffer isn't large enough only a portion of the bytes will be written |
| 69 | static size_t EffectsBufferBlock_WriteBytes |
| 70 | ( |
| 71 | const unsigned char *ptr, // data to write |
| 72 | size_t n, // number of bytes to write |
| 73 | struct EffectsBufferBlock *b // block to write to |
| 74 | ) { |
| 75 | // validations |
| 76 | ASSERT(n > 0); |
| 77 | ASSERT(b != NULL); |
| 78 | ASSERT(ptr != NULL); |
| 79 | |
| 80 | // determine number of bytes we can write |
| 81 | n = MIN(n, BLOCK_AVAILABLE_SPACE(b)); |
| 82 | |
| 83 | // write n bytes to buffer |
| 84 | memcpy(b->offset, ptr, n); |
| 85 | |
| 86 | // update offset |
| 87 | b->offset += n; |
| 88 | |
| 89 | return n; |
| 90 | } |
| 91 | |
| 92 | // write n bytes from ptr into effects-buffer |
| 93 | static void EffectsBuffer_WriteBytes |
no outgoing calls
no test coverage detected