bfr_read_string (BITCODE_RC *restrict *restrict src, int64_t size)
{
  uint16_t *ptr = (uint16_t *)*src;
  int32_t length = 0, wsize;
  DWGCHAR *str, *str_base;
  int i;

  if (size <= 0)
    return NULL;
  while (*ptr != 0 && length * 2 < size)
    {
      ptr++;
      length++;
    }

  wsize = length * sizeof (DWGCHAR) + sizeof (DWGCHAR);

  str = str_base = (DWGCHAR *)malloc (wsize);
  if (!str)
    {
      LOG_ERROR ("Out of memory");
      return NULL;
    }
  ptr = (uint16_t *)*src;
  for (i = 0; i < length; i++)
    {
      *str++ = (DWGCHAR) (*ptr++);
    }

  *src += size;
  *str = 0;

  return str_base;
}
bfr_read_string (BITCODE_RC *restrict *restrict src, int64_t size)
{
  uint16_t *ptr = (uint16_t *)*src;
  int32_t length = 0, wsize;
  DWGCHAR *str, *str_base;
  int i;

  if (size <= 0)
    return NULL;
  while (*ptr != 0 && length * 2 < size)
    {
      ptr++;
      length++;
    }

  wsize = length * sizeof (DWGCHAR) + sizeof (DWGCHAR);

  str = str_base = (DWGCHAR *)malloc (wsize);
  if (!str)
    {
      LOG_ERROR ("Out of memory");
      return NULL;
    }
  ptr = (uint16_t *)*src;
  for (i = 0; i < length; i++)
    {
      *str++ = (DWGCHAR) (*ptr++);
    }

  *src += size;
  *str = 0;

  return str_base;
}