Ignore:
Timestamp:
Mar 21, 2017, 12:21:04 PM (7 years ago)
Author:
Rob Schluntz <rschlunt@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
94a8123
Parents:
2c4bc81
Message:

change type of string literal from char[] to const char[]

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/tests/avltree/avl_test.c

    r2c4bc81 r142cf5d  
    2525
    2626  // int -> char *
    27   tree(int, char *) * smap = create(-1, "baz");
     27  tree(int, const char *) * smap = create(-1, "baz");
    2828  insert(&smap, 12, "bar");
    2929  insert(&smap, 2, "foo");
     
    3535  delete(smap);
    3636
    37   // char* -> char*
    38   struct c_str { char *str; };  // wraps a C string
    39   int ?<?(c_str a, c_str b) {
    40     return strcmp(a.str,b.str) < 0;
     37  // const char* -> const char*
     38  int ?<?(const char * a, const char * b) {
     39    return strcmp(a, b) < 0;
    4140  }
    42   tree(c_str, char *) * ssmap = create((c_str){"queso"}, "cheese");
    43   insert(&ssmap, (c_str){"foo"}, "bar");
    44   insert(&ssmap, (c_str){"hello"}, "world");
     41
     42  tree(const char *, const char *) * ssmap = create("queso", "cheese");
     43  insert(&ssmap, "foo", "bar");
     44  insert(&ssmap, "hello", "world");
    4545  assert( height(ssmap) == 2 );
    4646
    47   printf("%s %s %s\n", *find(ssmap, (c_str){"hello"}), *find(ssmap, (c_str){"foo"}), *find(ssmap, (c_str){"queso"}));
     47  printf("%s %s %s\n", *find(ssmap, "hello"), *find(ssmap, "foo"), *find(ssmap, "queso"));
    4848
    49   remove(&ssmap, (c_str){"foo"});
     49  remove(&ssmap, "foo");
    5050  delete(ssmap);
    5151}
Note: See TracChangeset for help on using the changeset viewer.