1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2024-12-23 17:33:50 +03:00

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
This commit is contained in:
Daniel Veillard 2002-01-18 16:23:55 +00:00
parent db5850a23a
commit 572577e094
4 changed files with 46 additions and 35 deletions

View File

@ -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

View File

@ -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;

64
xmlIO.c
View File

@ -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);
}
/**

View File

@ -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;