Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: code formatting

...

Code Block
bgColor#ffcccc
langc
#include <string.h>
#include <stdlib.h>

char * init_block(size_t block_size, size_t offset,
                 char *data, size_t data_size) {
  char * buffer = malloc(block_size);
  if (data_size > block_size || block_size - data_size > offset) {
    /* dataData won't fit in buffer, handle error */
  }
  memcpy(buffer + offset, data, data_size);
  return buffer;
}

...

Code Block
bgColor#ccccff
langc
#include <string.h>
#include <stdlib.h>

char * init_block(size_t block_size, size_t offset,
                 char * data, size_t data_size) {
  char * buffer = malloc(block_size);
  if (NULL == buffer) {
    /* handleHandle error */
  }
  if (data_size > block_size || block_size - data_size > offset) {
    /* dataData won't fit in buffer, handle error */
  }
  memcpy( buffer + offset, data, data_size);
  return buffer;
}

...