removed the last occurences of strdup usage in the code Daniel
* globals.c xmlIO.c xmlcatalog.c: removed the last occurences
of strdup usage in the code
Daniel
diff --git a/ChangeLog b/ChangeLog
index aaba724..c055fb8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Fri Jan 18 17:22:50 CET 2002 Daniel Veillard <daniel@veillard.com>
+
+ * globals.c xmlIO.c xmlcatalog.c: removed the last occurences
+ of strdup usage in the code
+
Fri Jan 18 12:47:15 CET 2002 Daniel Veillard <daniel@veillard.com>
* parser.c error.c: Keith Isdale complained rightly that
diff --git a/globals.c b/globals.c
index a66f0e8..d3e3feb 100644
--- a/globals.c
+++ b/globals.c
@@ -287,7 +287,7 @@
gs->xmlFree = (xmlFreeFunc) free;
gs->xmlMalloc = (xmlMallocFunc) malloc;
gs->xmlRealloc = (xmlReallocFunc) realloc;
- gs->xmlMemStrdup = (xmlStrdupFunc) strdup;
+ gs->xmlMemStrdup = (xmlStrdupFunc) xmlStrdup;
#endif
gs->xmlGenericErrorContext = NULL;
gs->xmlGetWarningsDefaultValue = 1;
diff --git a/xmlIO.c b/xmlIO.c
index 1bad043..016742c 100644
--- a/xmlIO.c
+++ b/xmlIO.c
@@ -962,56 +962,56 @@
*/
void *
-xmlIOHTTPOpenW( const char * post_uri, int compression ) {
+xmlIOHTTPOpenW(const char *post_uri, int compression)
+{
- xmlIOHTTPWriteCtxtPtr ctxt = NULL;
+ xmlIOHTTPWriteCtxtPtr ctxt = NULL;
- if ( post_uri == NULL )
- return ( NULL );
+ if (post_uri == NULL)
+ return (NULL);
- ctxt = xmlMalloc( sizeof( xmlIOHTTPWriteCtxt ) );
- if ( ctxt == NULL ) {
- xmlGenericError( xmlGenericErrorContext,
- "xmlIOHTTPOpenW: Failed to create output HTTP context.\n" );
- return ( NULL );
+ ctxt = xmlMalloc(sizeof(xmlIOHTTPWriteCtxt));
+ if (ctxt == NULL) {
+ xmlGenericError(xmlGenericErrorContext,
+ "xmlIOHTTPOpenW: Failed to create output HTTP context.\n");
+ return (NULL);
}
- (void)memset( ctxt, 0, sizeof( xmlIOHTTPWriteCtxt ) );
+ (void) memset(ctxt, 0, sizeof(xmlIOHTTPWriteCtxt));
- ctxt->uri = strdup( post_uri );
- if ( ctxt->uri == NULL ) {
- xmlGenericError( xmlGenericErrorContext,
- "xmlIOHTTPOpenW: Failed to duplicate destination URI.\n" );
- xmlFreeHTTPWriteCtxt( ctxt );
- return ( NULL );
+ ctxt->uri = (char *) xmlStrdup((const xmlChar *)post_uri);
+ if (ctxt->uri == NULL) {
+ xmlGenericError(xmlGenericErrorContext,
+ "xmlIOHTTPOpenW: Failed to duplicate destination URI.\n");
+ xmlFreeHTTPWriteCtxt(ctxt);
+ return (NULL);
}
/*
- ** Since the document length is required for an HTTP post,
- ** need to put the document into a buffer. A memory buffer
- ** is being used to avoid pushing the data to disk and back.
- */
+ * ** Since the document length is required for an HTTP post,
+ * ** need to put the document into a buffer. A memory buffer
+ * ** is being used to avoid pushing the data to disk and back.
+ */
#ifdef HAVE_ZLIB_H
- if ( ( compression > 0 ) && ( compression <= 9 ) ) {
-
- ctxt->compression = compression;
- ctxt->doc_buff = xmlCreateZMemBuff( compression );
- }
- else
+ if ((compression > 0) && (compression <= 9)) {
+
+ ctxt->compression = compression;
+ ctxt->doc_buff = xmlCreateZMemBuff(compression);
+ } else
#endif
{
- /* Any character conversions should have been done before this */
+ /* Any character conversions should have been done before this */
- ctxt->doc_buff = xmlAllocOutputBuffer( NULL );
+ ctxt->doc_buff = xmlAllocOutputBuffer(NULL);
}
- if ( ctxt->doc_buff == NULL ) {
- xmlFreeHTTPWriteCtxt( ctxt );
- ctxt = NULL;
+ if (ctxt->doc_buff == NULL) {
+ xmlFreeHTTPWriteCtxt(ctxt);
+ ctxt = NULL;
}
- return ( ctxt );
+ return (ctxt);
}
/**
diff --git a/xmlcatalog.c b/xmlcatalog.c
index 3f15369..e0828fa 100644
--- a/xmlcatalog.c
+++ b/xmlcatalog.c
@@ -72,17 +72,23 @@
return (line_read);
#else
char line_read[501];
+ char *ret;
+ int len;
if (prompt != NULL)
fprintf(stdout, "%s", prompt);
if (!fgets(line_read, 500, stdin))
return(NULL);
line_read[500] = 0;
- return(strdup(line_read));
+ len = strlen(line_read);
+ ret = (char *) malloc(len + 1);
+ if (ret != NULL) {
+ memcpy (ret, line_read, len + 1);
+ }
+ return(ret);
#endif
}
-
static void usershell(void) {
char *cmdline = NULL, *cur;
int nbargs;