Added new functions for atom entry.
authorThadeu Lima de Souza Cascardo <cascardo@minaslivre.org>
Sun, 27 Jan 2008 03:30:08 +0000 (01:30 -0200)
committerThadeu Lima de Souza Cascardo <cascardo@minaslivre.org>
Sun, 27 Jan 2008 03:30:08 +0000 (01:30 -0200)
atom/entry.c
include/atompub/entry.h

index c0fed59..c1385d1 100644 (file)
@@ -31,8 +31,28 @@ Atom *
 atom_new_data_len (char *data, size_t len)
 {
   Atom *atom = g_slice_new (Atom);
-  atom->data = data;
+  atom->data = g_malloc (len);
+  memcpy (atom->data, data, len);
   atom->len = len;
   return atom;
 }
 
+void
+atom_delete (Atom *atom)
+{
+  if (atom->data)
+    g_free (atom->data);
+  g_slice_free (Atom, atom);
+}
+
+char *
+atom_string (Atom *atom)
+{
+  return atom->data;
+}
+
+size_t
+atom_len (Atom *atom)
+{
+  return atom->len;
+}
index a0806d9..0bf4253 100644 (file)
@@ -25,5 +25,8 @@
 typedef struct _atom_entry Atom;
 
 Atom * atom_new_data_len (char *, size_t);
+void atom_delete (Atom *);
+char * atom_string (Atom *);
+size_t atom_len (Atom *);
 
 #endif