Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(218)

Side by Side Diff: src/cmd/dist/README

Issue 7232060: code review 7232060: cmd/dist: fix code example in README (Closed)
Patch Set: diff -r c7d3755060da https://code.google.com/p/go/ Created 12 years, 1 month ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 This program, dist, is the bootstrapping tool for the Go distribution. 1 This program, dist, is the bootstrapping tool for the Go distribution.
2 It takes care of building the C programs (like the Go compiler) and 2 It takes care of building the C programs (like the Go compiler) and
3 the initial bootstrap copy of the go tool. It also serves as a catch-all 3 the initial bootstrap copy of the go tool. It also serves as a catch-all
4 to replace odd jobs previously done with shell scripts. 4 to replace odd jobs previously done with shell scripts.
5 5
6 Dist is itself written in very simple C. All interaction with C libraries, 6 Dist is itself written in very simple C. All interaction with C libraries,
7 even standard C libraries, is confined to a single system-specific file 7 even standard C libraries, is confined to a single system-specific file
8 (plan9.c, unix.c, windows.c), to aid portability. Functionality needed 8 (plan9.c, unix.c, windows.c), to aid portability. Functionality needed
9 by other files should be exposed via the portability layer. Functions 9 by other files should be exposed via the portability layer. Functions
10 in the portability layer begin with an x prefix when they would otherwise 10 in the portability layer begin with an x prefix when they would otherwise
(...skipping 13 matching lines...) Expand all
24 Buf b1, b2; 24 Buf b1, b2;
25 Vec v1; 25 Vec v1;
26 ················ 26 ················
27 binit(&b1); 27 binit(&b1);
28 binit(&b2); 28 binit(&b2);
29 vinit(&v1); 29 vinit(&v1);
30 ················ 30 ················
31 ... main code ... 31 ... main code ...
32 bprintf(&b1, "hello, world"); 32 bprintf(&b1, "hello, world");
33 vadd(&v1, bstr(&b1)); // v1 takes a copy of its argument 33 vadd(&v1, bstr(&b1)); // v1 takes a copy of its argument
34 » » bprintf(&b1, "another string"); 34 » » bprintf(&b2, "another string");
35 » » vadd(&v1, bstr(&b1)); // v1 now has two strings 35 » » vadd(&v1, bstr(&b2)); // v1 now has two strings
36 ················ 36 ················
37 bfree(&b1); 37 bfree(&b1);
38 bfree(&b2); 38 bfree(&b2);
39 vfree(&v1); 39 vfree(&v1);
40 } 40 }
41 ········ 41 ········
42 The binit/vinit calls prepare a buffer or vector for use, initializing the· 42 The binit/vinit calls prepare a buffer or vector for use, initializing the·
43 data structures, and the bfree/vfree calls free any memory they are still 43 data structures, and the bfree/vfree calls free any memory they are still
44 holding onto. Use of this idiom gives us lexically scoped allocations. 44 holding onto. Use of this idiom gives us lexically scoped allocations.
45 45
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b