コード例 #1
0
ファイル: list.c プロジェクト: smtlaissezfaire/loop_c
static string printList(Object self) {
  Object next;
  int first = 1;
  string str = calloc(2, sizeof(string));

  if (!list_p(self)) {
    exitWithMessage(-2, "Internal error in printList");
  }

  str = alloc_strcat(str, "(");

  for (next = self ;;) {
    if (empty_p(next)) {
      str = alloc_strcat(str, ")");
      break;
    } else {
      if (first) {
        first = 0;
      } else {
        str = alloc_strcat(str, " ");
      }

      if (next->type == LIST) {
        str = alloc_strcat(str, car(next)->print(car(next)));
        next = cdr(next);
      } else {
        str = alloc_strcat(str, ". ");
        str = alloc_strcat(str, next->print(next));
        str = alloc_strcat(str, ")");
        break;
      }
    }
  }

  return str;
}
コード例 #2
0
ファイル: utils.c プロジェクト: trorornmn/ctumblr
static size_t write_data(char *buffer, size_t size, size_t nmemb, void *rep) {
	*(buffer + size * nmemb) = '\0';
	alloc_strcat((char**)rep, buffer);

	return size * nmemb;
}