Пример #1
0
void M_BufferWrite(buf_t *buf, const void *data, size_t size) {
  M_BufferEnsureCapacity(buf, size);
  memcpy(buf->data + buf->cursor, data, size);
  buf->cursor += size;

  check_cursor(buf);
}
Пример #2
0
void M_BufferWriteString(buf_t *buf, const char *string, size_t length) {
  M_BufferEnsureCapacity(buf, length + 1);
  strncpy(buf->data + buf->cursor, string, length + 1);
  buf->cursor += (length + 1);

  check_cursor(buf);
}
Пример #3
0
void M_BufferWriteZeros(buf_t *buf, size_t count) {
  int i;

  M_BufferEnsureCapacity(buf, count);

  for (i = 0; i < count; i++)
    buf->data[buf->cursor++] = 0;

  check_cursor(buf);
}
Пример #4
0
void M_BufferWriteBools(buf_t *buf, dboolean *bools, size_t count) {
  size_t i;
  M_BufferEnsureCapacity(buf, count * sizeof(dboolean));

  for (i = 0; i < count; i++) {
    union bool_bytes bb;

    bb.b = bools[i];
    M_BufferWriteUChars(buf, bb.c, 4);
  }
}
Пример #5
0
void M_BufferWriteDoubles(buf_t *buf, double *doubles, size_t count) {
  size_t i;

  M_BufferEnsureCapacity(buf, count * sizeof(double));

  for (i = 0; i < count; i++) {
    union double_bytes db;

    db.d = doubles[i];
    M_BufferWriteUChars(buf, db.c, 8);
  }
}
Пример #6
0
void M_BufferWriteFloats(buf_t *buf, float *floats, size_t count) {
  size_t i;

  M_BufferEnsureCapacity(buf, count * sizeof(float));

  for (i = 0; i < count; i++) {
    union float_bytes fb;

    fb.f = floats[i];
    M_BufferWriteUChars(buf, fb.c, 4);
  }
}
Пример #7
0
void M_BufferWriteULongs(buf_t *buf, uint64_t *ulongs, size_t count) {
  size_t i;

  M_BufferEnsureCapacity(buf, count * sizeof(uint64_t));

  for (i = 0; i < count; i++) {
    union ulong_bytes lb;

    lb.l = ulongs[i];
    M_BufferWriteUChars(buf, lb.c, 8);
  }
}
Пример #8
0
void M_BufferWriteUInts(buf_t *buf, unsigned int *uints, size_t count) {
  size_t i;

  M_BufferEnsureCapacity(buf, count * sizeof(unsigned int));

  for (i = 0; i < count; i++) {
    union uint_bytes ib;

    ib.i = uints[i];
    M_BufferWriteUChars(buf, ib.c, 4);
  }
}
Пример #9
0
void M_BufferWriteUShorts(buf_t *buf, unsigned short *ushorts, size_t count) {
  size_t i;

  M_BufferEnsureCapacity(buf, count * sizeof(unsigned short));

  for (i = 0; i < count; i++) {
    union ushort_bytes sb;

    sb.s = ushorts[i];
    M_BufferWriteUChars(buf, sb.c, 2);
  }
}
Пример #10
0
void M_BufferWriteDoubles(buf_t *buf, const double *doubles, size_t count) {
  M_BufferEnsureCapacity(buf, count * sizeof(double));
  M_BufferWriteChars(buf, (char *)doubles, count * sizeof(doubles));
}
Пример #11
0
void M_BufferWriteFloats(buf_t *buf, const float *floats, size_t count) {
  M_BufferEnsureCapacity(buf, count * sizeof(float));
  M_BufferWriteChars(buf, (char *)floats, count * sizeof(floats));
}
Пример #12
0
void M_BufferWriteULongs(buf_t *buf, const uint_64_t *ulongs, size_t count) {
  M_BufferEnsureCapacity(buf, count * sizeof(int_64_t));
  M_BufferWriteChars(buf, (char *)ulongs, count * sizeof(uint_64_t));
}
Пример #13
0
void M_BufferWriteUInts(buf_t *buf, const unsigned int *uints, size_t count) {
  M_BufferEnsureCapacity(buf, count * sizeof(unsigned int));
  M_BufferWriteChars(buf, (char *)uints, count * sizeof(unsigned int));
}
Пример #14
0
void M_BufferWriteInts(buf_t *buf, const int *ints, size_t count) {
  M_BufferEnsureCapacity(buf, count * sizeof(int));
  M_BufferWriteChars(buf, (char *)ints, count * sizeof(int));
}
Пример #15
0
void M_BufferWriteShorts(buf_t *buf, const short *shorts, size_t count) {
  M_BufferEnsureCapacity(buf, count * sizeof(short));
  M_BufferWriteChars(buf, (char *)shorts, count * sizeof(short));
}
Пример #16
0
void M_BufferWriteBools(buf_t *buf, const bool *bools, size_t count) {
  M_BufferEnsureCapacity(buf, count * sizeof(bool));
  M_BufferWriteChars(buf, (char *)bools, count * sizeof(bool));
}