summaryrefslogtreecommitdiffhomepage
path: root/examples
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2022-12-05 22:17:59 +0100
committerTyge Løvset <[email protected]>2022-12-05 22:17:59 +0100
commit0eadaa1220e1ba0382638067aaf8566c216765fd (patch)
tree5c85ee0180526184084196ff0d2da5462e02bcd2 /examples
parent11b835f89aca22d7d42edefbf31ca7e6d0d61b61 (diff)
downloadSTC-modified-0eadaa1220e1ba0382638067aaf8566c216765fd.tar.gz
STC-modified-0eadaa1220e1ba0382638067aaf8566c216765fd.zip
Minor corrections/changes.
Diffstat (limited to 'examples')
-rw-r--r--examples/new_arr.c6
-rw-r--r--examples/prime.c2
-rw-r--r--examples/regex_replace.c2
3 files changed, 5 insertions, 5 deletions
diff --git a/examples/new_arr.c b/examples/new_arr.c
index 51955b46..79e7c7a6 100644
--- a/examples/new_arr.c
+++ b/examples/new_arr.c
@@ -13,7 +13,7 @@ int main()
{
int w = 7, h = 5, d = 3;
- c_autodrop (carr2_int, volume, carr2_int_new_uninit(w, h))
+ c_with (carr2_int volume = carr2_int_new_uninit(w, h), carr2_int_drop(&volume))
{
int *dat = carr2_int_data(&volume);
for (size_t i = 0; i < carr2_int_size(&volume); ++i)
@@ -29,7 +29,7 @@ int main()
puts("\n");
}
- c_autodrop (carr3_int, volume, carr3_int_new_uninit(w, h, d))
+ c_with (carr3_int volume = carr3_int_new_uninit(w, h, d), carr3_int_drop(&volume))
{
int *dat = carr3_int_data(&volume);
for (size_t i = 0; i < carr3_int_size(&volume); ++i)
@@ -46,7 +46,7 @@ int main()
puts("");
}
- c_autodrop (carr2_str, text2d, carr2_str_with_size(h, d, cstr_init()))
+ c_with (carr2_str text2d = carr2_str_with_size(h, d, cstr_null), carr2_str_drop(&text2d))
{
cstr_assign(&text2d.data[2][1], "hello");
cstr_assign(&text2d.data[4][0], "world");
diff --git a/examples/prime.c b/examples/prime.c
index d2fc5efa..287fb69b 100644
--- a/examples/prime.c
+++ b/examples/prime.c
@@ -28,7 +28,7 @@ int main(void)
printf("computing prime numbers up to %" c_ZU "\n", n);
clock_t t1 = clock();
- c_autodrop (cbits, primes, sieveOfEratosthenes(n + 1)) {
+ c_with (cbits primes = sieveOfEratosthenes(n + 1), cbits_drop(&primes)) {
puts("done");
size_t np = cbits_count(&primes);
clock_t t2 = clock();
diff --git a/examples/regex_replace.c b/examples/regex_replace.c
index 4091a59e..e88c559f 100644
--- a/examples/regex_replace.c
+++ b/examples/regex_replace.c
@@ -34,7 +34,7 @@ int main()
printf("brack: %s\n", cstr_str(&str));
/* Shows how to compile RE separately */
- c_autodrop (cregex, re, cregex_from(pattern, cre_default)) {
+ c_with (cregex re = cregex_from(pattern, cre_default), cregex_drop(&re)) {
if (cregex_captures(&re) == 0)
continue; // break c_with
/* European date format. */