Commit 572577e0 authored by Daniel Veillard's avatar Daniel Veillard
Browse files

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
parent db5850a2
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
......
......@@ -287,7 +287,7 @@ xmlInitializeGlobalState(xmlGlobalStatePtr gs)
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;
......
......@@ -962,56 +962,56 @@ xmlIOHTTPOpen (const char *filename) {
*/
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);
}
/**
......
......@@ -72,17 +72,23 @@ xmlShellReadline(const char *prompt) {
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;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment