|
7 | 7 | <link rel="stylesheet" href="checker.css"> |
8 | 8 | <script src="js-yaml.min.js"></script> |
9 | 9 | <script src="checker.js"></script> |
| 10 | +<script src="free.js"></script> |
10 | 11 | <link rel="license" href="https://creativecommons.org/licenses/by/4.0/"> |
11 | 12 |
|
12 | 13 | <!-- See create_labs.md for how to create your own lab! --> |
13 | 14 |
|
14 | | -<!-- Sample expected answer --> |
15 | | -<script id="expected0" type="plain/text"> |
16 | | - asprintf(&result, "pre_%s_post", s); |
17 | | - free(s); |
18 | | - return result; |
19 | | -</script> |
20 | | - |
21 | | -<!-- Full pattern of correct answer --> |
22 | | -<script id="correct0" type="plain/text"> |
23 | | -\s* |
24 | | - asprintf \( & result , "pre_%s_post" , s \) ; |
25 | | - free \( s \) ; |
26 | | - return result ; |
27 | | -\s* |
28 | | -</script> |
29 | | - |
30 | | -<script id="info" type="application/yaml"> |
31 | | ---- |
32 | | -hints: |
33 | | -- present: |- |
34 | | - \s*free[^;]*; asprintf |
35 | | - text: Do not free the input first, you need to use it. |
36 | | - examples: |
37 | | - - - |- |
38 | | - free(s); |
39 | | - asprintf(&result, "pre_%s_post", s); |
40 | | -- present: |- |
41 | | - \s* asprintf \( |
42 | | - absent: free |
43 | | - text: This fails to free the memory, likely leading to a missing release. |
44 | | - examples: |
45 | | - - - |- |
46 | | - asprintf(&result, ""pre_%s_post"", s); |
47 | | -- absent: return |
48 | | - text: This fails to return the result. |
49 | | -- absent: |- |
50 | | - \s* [^;]+;[^;]+;[^;]+; \s* |
51 | | - text: There should be 3 statements, each terminated with a semicolon. |
52 | | - examples: |
53 | | - - - |- |
54 | | - asprintf(&result, "pre_%s_post", s); |
55 | | - free(s); |
56 | | - return result |
57 | | -- present: |- |
58 | | - \s* return result ; free \s* |
59 | | - text: Do not do anything after the return, it will not execute. |
60 | | - examples: |
61 | | - - - |- |
62 | | - asprintf(&result, "pre_%s_post", s); |
63 | | - return result; |
64 | | - free(s); |
65 | | -# debug: true |
66 | | -</script> |
67 | 15 | </head> |
68 | 16 | <body> |
69 | 17 | <!-- For GitHub Pages formatting: --> |
|
0 commit comments