object b4514422b6ebe590e56622e382993d9f070561e9

0 views
Skip to first unread message

letha...@gmail.com

unread,
May 24, 2009, 11:19:19 AM5/24/09
to syx-c...@googlegroups.com
Branch: object
commit b4514422b6ebe590e56622e382993d9f070561e9
Author: Luca Bruno <letha...@gmail.com>
Date: Sun May 24 17:18:36 2009 +0200

Ensure valid syx initialization in embedding examples.

:100644 100644 3117090... 33b3af7... M ChangeLog
:100644 100644 5b53bcc... 034e5fa... M examples/embedding/average.c
:100644 100644 86c86a2... 6c5f433... M examples/embedding/do-me.c
:100644 100644 56ea9ec... 2160518... M examples/embedding/init.c
:100644 100644 ea2bb34... 44f8711... M syx/syx-utils.c

diff --git a/ChangeLog b/ChangeLog
index 3117090..33b3af7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,7 @@
2009-05-24 Luca Bruno <letha...@gmail.com>

+ * examples/embedding/*.c (main): sanitize syx initialization
+
* syx/syx-utils.c (syx_file_exists): added

* syx/syx-primitives.c (FileStream_fileOp): free obtained string with #next:, fixes memory leak
diff --git a/examples/embedding/average.c b/examples/embedding/average.c
index 5b53bcc..034e5fa 100644
--- a/examples/embedding/average.c
+++ b/examples/embedding/average.c
@@ -36,10 +36,12 @@ SYX_FUNC_PRIMITIVE(average)
int main (int argc, char *argv[])
{
/* initialize Syx */
- syx_init (argc, argv, NULL);
+ if (!syx_init (argc, argv, NULL))
+ syx_error ("Couldn't initialize Syx");

/* load the default image */
- syx_memory_load_image (NULL);
+ if (!syx_memory_load_image (NULL))
+ syx_error ("Couldn't load image");

/* now file in our file in blocking mode, .i.e without scheduling the Process */
syx_file_in_blocking ("average.st");
diff --git a/examples/embedding/do-me.c b/examples/embedding/do-me.c
index 86c86a2..6c5f433 100644
--- a/examples/embedding/do-me.c
+++ b/examples/embedding/do-me.c
@@ -3,10 +3,12 @@
int main (int argc, char *argv[])
{
/* initialize Syx */
- syx_init (argc, argv, NULL);
+ if (!syx_init (argc, argv, NULL))
+ syx_error ("Couldn't initialize Syx");

/* load the default image */
- syx_memory_load_image (NULL);
+ if (!syx_memory_load_image (NULL))
+ syx_error ("Couldn't load image");

/* now file in our file in blocking mode, .i.e without scheduling the Process */
syx_file_in_blocking ("do-me.st");
diff --git a/examples/embedding/init.c b/examples/embedding/init.c
index 56ea9ec..2160518 100644
--- a/examples/embedding/init.c
+++ b/examples/embedding/init.c
@@ -3,10 +3,12 @@
int main (int argc, char *argv[])
{
/* initialize Syx */
- syx_init (argc, argv, NULL);
+ if (!syx_init (argc, argv, NULL))
+ syx_error ("Couldn't initialize Syx");

/* load the default image */
- syx_memory_load_image (NULL);
+ if (!syx_memory_load_image (NULL))
+ syx_error ("Couldn't load image");

/* cleanup Syx */
syx_quit ();
diff --git a/syx/syx-utils.c b/syx/syx-utils.c
index ea2bb34..44f8711 100644
--- a/syx/syx-utils.c
+++ b/syx/syx-utils.c
@@ -655,10 +655,11 @@ syx_find_first_non_whitespace (syx_symbol string)
syx_bool
syx_file_exists (syx_symbol filename)
{
+ FILE *f;
if (!filename)
return FALSE;

- FILE *f = fopen (filename, "r");
+ f = fopen (filename, "r");
if (f)
{
fclose (f);

Reply all
Reply to author
Forward
0 new messages