summaryrefslogtreecommitdiff
path: root/src/cr-pseudo.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/cr-pseudo.c')
-rw-r--r--src/cr-pseudo.c48
1 files changed, 34 insertions, 14 deletions
diff --git a/src/cr-pseudo.c b/src/cr-pseudo.c
index abb4f9b..a46e69e 100644
--- a/src/cr-pseudo.c
+++ b/src/cr-pseudo.c
@@ -24,37 +24,51 @@
#include "cr-pseudo.h"
/**
- *@file
+ *@CRPseudo:
*The definition of the #CRPseudo class.
*/
/**
+ * cr_pseudo_new:
*Constructor of the #CRPseudo class.
- *@return the newly build instance.
+ *
+ *Returns the newly build instance.
*/
CRPseudo *
cr_pseudo_new (void)
{
- CRPseudo *result = (CRPseudo *)g_malloc0 (sizeof (CRPseudo));
+ CRPseudo *result = NULL;
+
+ result = g_malloc0 (sizeof (CRPseudo));
return result;
}
+/**
+ * cr_pseudo_to_string:
+ * @a_this: the current instance of #CRPseud.
+ *
+ * Returns the serialized pseudo. Caller must free the returned
+ * string using g_free().
+ */
guchar *
-cr_pseudo_to_string (CRPseudo * a_this)
+cr_pseudo_to_string (CRPseudo const * a_this)
{
guchar *result = NULL;
+ GString *str_buf = NULL;
g_return_val_if_fail (a_this, NULL);
- GString *str_buf = (GString *)g_string_new (NULL);
+ str_buf = g_string_new (NULL);
if (a_this->type == IDENT_PSEUDO) {
+ guchar *name = NULL;
- if (a_this->name == NULL)
+ if (a_this->name == NULL) {
goto error;
+ }
- gchar *name = g_strndup (a_this->name->stryng->str,
+ name = g_strndup (a_this->name->stryng->str,
a_this->name->stryng->len);
if (name) {
@@ -63,12 +77,13 @@ cr_pseudo_to_string (CRPseudo * a_this)
name = NULL;
}
} else if (a_this->type == FUNCTION_PSEUDO) {
- gchar *arg = NULL;
+ guchar *name = NULL,
+ *arg = NULL;
if (a_this->name == NULL)
goto error;
- gchar *name = g_strndup (a_this->name->stryng->str,
+ name = g_strndup (a_this->name->stryng->str,
a_this->name->stryng->len);
if (a_this->extra) {
@@ -92,7 +107,7 @@ cr_pseudo_to_string (CRPseudo * a_this)
}
if (str_buf) {
- result = (guchar *)str_buf->str;
+ result = str_buf->str;
g_string_free (str_buf, FALSE);
str_buf = NULL;
}
@@ -105,12 +120,15 @@ cr_pseudo_to_string (CRPseudo * a_this)
}
/**
+ * cr_pseudo_dump:
+ *@a_this: the current instance of pseudo
+ *@a_fp: the destination file pointer.
+ *
*Dumps the pseudo to a file.
- *@param a_this the current instance of pseudo
- *@param a_fp the destination file pointer.
+ *
*/
void
-cr_pseudo_dump (CRPseudo * a_this, FILE * a_fp)
+cr_pseudo_dump (CRPseudo const * a_this, FILE * a_fp)
{
guchar *tmp_str = NULL;
@@ -125,8 +143,10 @@ cr_pseudo_dump (CRPseudo * a_this, FILE * a_fp)
}
/**
+ * cr_pseudo_destroy:
+ *@a_this: the current instance to destroy.
+ *
*destructor of the #CRPseudo class.
- *@param a_this the current instance to destroy.
*/
void
cr_pseudo_destroy (CRPseudo * a_this)