Modify interface to get string from entry
authorThadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
Sat, 9 Aug 2008 21:41:38 +0000 (18:41 -0300)
committerThadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
Sat, 9 Aug 2008 21:43:03 +0000 (18:43 -0300)
atom/entry.c
frontend/cgi/cgi.c
include/atompub/entry.h

index d366500..ed59683 100644 (file)
@@ -157,21 +157,8 @@ atom_entry_summary_set (AtomEntry *entry, char *summary)
   entry->summary = g_strdup (summary);
 }
 
-char *
-atom_entry_string (AtomEntry *entry)
-{
-  char *buffer;
-  int size;
-  xmlDocDumpMemory (entry->doc, &buffer, &size);
-  return buffer;
-}
-
-size_t
-atom_entry_len (AtomEntry *entry)
+void
+atom_entry_string (AtomEntry *entry, char **buffer, size_t *len)
 {
-  char *buffer;
-  int size;
-  xmlDocDumpMemory (entry->doc, &buffer, &size);
-  xmlFree (buffer);
-  return size;
+  xmlDocDumpMemory (entry->doc, buffer, len);
 }
index 7e80b7d..5497941 100644 (file)
@@ -45,9 +45,13 @@ cgi_serve_request (AtomCtx *ctx)
       iri_delete (iri);
       if (atom)
        {
+         char * str;
+         size_t len;
          char *header = "Content-type: application/atom+xml\n\n";
          write (1, header, strlen (header));
-         write (1, atom_entry_string (atom), atom_entry_len (atom));
+         atom_entry_string (atom, &str, &len);
+         write (1, str, len);
+         g_free (str);
          atom_entry_delete (atom);
        }
       else if ((error = atom_error_get (ctx)) != NULL)
index d577894..e531e96 100644 (file)
@@ -36,7 +36,6 @@ AtomPerson * atom_entry_person (AtomEntry *);
 void atom_entry_person_set (AtomEntry *, AtomPerson *);
 char * atom_entry_summary (AtomEntry *);
 void atom_entry_summary_set (AtomEntry *, char *);
-char * atom_entry_string (AtomEntry *);
-size_t atom_entry_len (AtomEntry *);
+void atom_entry_string (AtomEntry *, char **, size_t *);
 
 #endif