Simplify in a lot of places using odr_strdupn
[yaz-moved-to-github.git] / src / srwutil.c
index 2591fc9..ae8ecae 100644 (file)
@@ -246,9 +246,7 @@ static void grab_charset(ODR o, const char *content_type, char **charset)
             while (i < 20 && charset_p[i] &&
                    !strchr("; \n\r", charset_p[i]))
                 i++;
-            *charset = (char*) odr_malloc(o, i+1);
-            memcpy(*charset, charset_p, i);
-            (*charset)[i] = '\0';
+            *charset = odr_strdupn(o, charset_p, i);
         }
     }
 }
@@ -1182,6 +1180,9 @@ void yaz_encode_sru_extra(Z_SRW_PDU *sr, ODR odr, const char *extra_args)
         Z_SRW_extra_arg **ea = &sr->extra_args;
         yaz_uri_to_array(extra_args, odr, &name, &val);
 
+        /** append rather than override */
+        while (*ea)
+            ea = &(*ea)->next;
         while (*name)
         {
             *ea = (Z_SRW_extra_arg *) odr_malloc(odr, sizeof(**ea));