fork download
  1. static int _rb_range(struct rb_tree *tree, struct rb_node *node, void *range, void *cookie,
  2. int (*comp)(const void *, const void *), int (*call)(void *, void *))
  3. {
  4. int test, error;
  5.  
  6. if (node != rb_nil(tree)) {
  7. test = comp(range, node->data);
  8. if (test <= 0) {
  9. if ((error = _rb_range(tree, node->left, range, cookie, comp, call)) != 0) {
  10. return error;
  11. }
  12. if (test < 0) {
  13. return 1;
  14. }
  15. if ((error = call(node->data, cookie)) != 0) {
  16. return error;
  17. }
  18. }
  19. if ((error = _rb_range(tree, node->right, range, cookie, comp, call)) != 0) {
  20. return error;
  21. }
  22. }
  23. return 0;
  24. }
  25.  
  26. int rb_range(struct rb_tree *tree, void *range, void *cookie,
  27. int (*comp)(const void *, const void *), int (*call)(void *, void *))
  28. {
  29. struct rb_node *node = rb_first(tree);
  30. int res;
  31.  
  32. while (node != rb_nil(tree)) {
  33. if ((res = comp(range, node->data)) == 0) {
  34. return _rb_range(tree, node, range, cookie, comp, call);
  35. }
  36. node = res < 0 ? node->left : node->right;
  37. }
  38. return -1;
  39. }
  40.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.c:1:51: warning: 'struct rb_node' declared inside parameter list
 static int _rb_range(struct rb_tree *tree, struct rb_node *node, void *range, void *cookie, int (*comp)(const void *, const void *), int (*call)(void *, void *))
                                                   ^
prog.c:1:51: warning: its scope is only this definition or declaration, which is probably not what you want
prog.c:1:51: warning: 'struct rb_tree' declared inside parameter list
prog.c: In function '_rb_range':
prog.c:5:14: warning: implicit declaration of function 'rb_nil' [-Wimplicit-function-declaration]
  if (node != rb_nil(tree)) {
              ^
prog.c:5:11: warning: comparison between pointer and integer
  if (node != rb_nil(tree)) {
           ^
prog.c:6:26: error: dereferencing pointer to incomplete type 'struct rb_node'
   test = comp(range, node->data);
                          ^
prog.c: At top level:
prog.c:30:21: warning: 'struct rb_tree' declared inside parameter list
 int rb_range(struct rb_tree *tree, void *range, void *cookie, int (*comp)(const void *, const void *), int (*call)(void *, void *))
                     ^
prog.c: In function 'rb_range':
prog.c:32:25: warning: implicit declaration of function 'rb_first' [-Wimplicit-function-declaration]
  struct rb_node *node = rb_first(tree);
                         ^
prog.c:32:25: warning: initialization makes pointer from integer without a cast [-Wint-conversion]
prog.c:35:14: warning: comparison between pointer and integer
  while (node != rb_nil(tree)) {
              ^
prog.c:36:30: error: dereferencing pointer to incomplete type 'struct rb_node'
   if ((res = comp(range, node->data)) == 0) {
                              ^
prog.c:37:21: warning: passing argument 1 of '_rb_range' from incompatible pointer type [-Wincompatible-pointer-types]
    return _rb_range(tree, node, range, cookie, comp, call);
                     ^
prog.c:1:12: note: expected 'struct rb_tree *' but argument is of type 'struct rb_tree *'
 static int _rb_range(struct rb_tree *tree, struct rb_node *node, void *range, void *cookie, int (*comp)(const void *, const void *), int (*call)(void *, void *))
            ^
prog.c:37:27: warning: passing argument 2 of '_rb_range' from incompatible pointer type [-Wincompatible-pointer-types]
    return _rb_range(tree, node, range, cookie, comp, call);
                           ^
prog.c:1:12: note: expected 'struct rb_node *' but argument is of type 'struct rb_node *'
 static int _rb_range(struct rb_tree *tree, struct rb_node *node, void *range, void *cookie, int (*comp)(const void *, const void *), int (*call)(void *, void *))
            ^
stdout
Standard output is empty