[Mplayer-cvslog] CVS: main url.c,1.1,1.2 url.h,1.1,1.2

Bertrand Baudet bertrand at users.sourceforge.net
Sun May 20 14:42:17 CEST 2001


Update of /cvsroot/mplayer/main
In directory usw-pr-cvs1:/tmp/cvs-serv27171

Modified Files:
	url.c url.h 
Log Message:
Added initialisation of URL pointers.
Added null terminaison to string.


Index: url.c
===================================================================
RCS file: /cvsroot/mplayer/main/url.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** url.c	2001/05/18 16:14:06	1.1
--- url.c	2001/05/20 12:42:14	1.2
***************
*** 17,20 ****
--- 17,27 ----
  		exit(1);
  	}
+ 	// Initialisation of the URL container members
+ 	Curl->url = NULL;
+ 	Curl->protocol = NULL;
+ 	Curl->hostname = NULL;
+ 	Curl->file = NULL;
+ 	Curl->port = 0;
+ 
  	// Copy the url in the URL container
  	Curl->url = (char*)malloc(strlen(url)+1);
***************
*** 28,32 ****
  	ptr1 = strstr(url, "://");
  	if( ptr1==NULL ) {
! 		printf("Malformed URL!\n");
  		return NULL;
  	}
--- 35,39 ----
  	ptr1 = strstr(url, "://");
  	if( ptr1==NULL ) {
! 		printf("Malformed URL or not an URL!\n");
  		return NULL;
  	}
***************
*** 63,66 ****
--- 70,74 ----
  	}
  	strncpy(Curl->hostname, ptr1+3, pos2-pos1-3);
+ 	Curl->hostname[pos2-pos1-3] = '\0';
  
  	// Look if a path is given
***************
*** 71,80 ****
  		if( strlen(ptr2)>1 ) {
  			// copy the path/filename in the URL container
! 			Curl->path = (char*)malloc(strlen(ptr2));
! 			if( Curl->path==NULL ) {
  				printf("Memory allocation failed!\n");
  				exit(1);
  			}
! 			strcpy(Curl->path, ptr2+1);
  		}
  	}
--- 79,88 ----
  		if( strlen(ptr2)>1 ) {
  			// copy the path/filename in the URL container
! 			Curl->file = (char*)malloc(strlen(ptr2));
! 			if( Curl->file==NULL ) {
  				printf("Memory allocation failed!\n");
  				exit(1);
  			}
! 			strcpy(Curl->file, ptr2+1);
  		}
  	}
***************
*** 89,93 ****
  	if(url->protocol) free(url->protocol);
  	if(url->hostname) free(url->hostname);
! 	if(url->path) free(url->path);
  	free(url);
  }
--- 97,101 ----
  	if(url->protocol) free(url->protocol);
  	if(url->hostname) free(url->hostname);
! 	if(url->file) free(url->file);
  	free(url);
  }

Index: url.h
===================================================================
RCS file: /cvsroot/mplayer/main/url.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** url.h	2001/05/18 16:14:06	1.1
--- url.h	2001/05/20 12:42:14	1.2
***************
*** 6,10 ****
  	char *protocol;
  	char *hostname;
! 	char *path;
  	unsigned int port;
  } URL_t;
--- 6,10 ----
  	char *protocol;
  	char *hostname;
! 	char *file;
  	unsigned int port;
  } URL_t;


_______________________________________________
Mplayer-cvslog mailing list
Mplayer-cvslog at lists.sourceforge.net
http://lists.sourceforge.net/lists/listinfo/mplayer-cvslog



More information about the MPlayer-cvslog mailing list