ia64/xen-unstable

changeset 15686:eabac09d9e4e

xenstored: Remove unused util code.
Signed-off-by: Keir Fraser <keir@xensource.com>
author kfraser@localhost.localdomain
date Wed Aug 01 12:05:42 2007 +0100 (2007-08-01)
parents ad9a79db3839
children 0c79a9414f8d
files tools/xenstore/utils.c tools/xenstore/utils.h
line diff
     1.1 --- a/tools/xenstore/utils.c	Wed Aug 01 09:11:08 2007 +0100
     1.2 +++ b/tools/xenstore/utils.c	Wed Aug 01 12:05:42 2007 +0100
     1.3 @@ -61,72 +61,3 @@ void barf_perror(const char *fmt, ...)
     1.4  	}
     1.5  	exit(1);
     1.6  }
     1.7 -
     1.8 -void *_realloc_array(void *ptr, size_t size, size_t num)
     1.9 -{
    1.10 -	if (num >= SIZE_MAX/size)
    1.11 -		return NULL;
    1.12 -	return realloc_nofail(ptr, size * num);
    1.13 -}
    1.14 -
    1.15 -void *realloc_nofail(void *ptr, size_t size)
    1.16 -{
    1.17 -	ptr = realloc(ptr, size);
    1.18 -	if (ptr)
    1.19 -		return ptr;
    1.20 -	barf("realloc of %zu failed", size);
    1.21 -}
    1.22 -
    1.23 -void *malloc_nofail(size_t size)
    1.24 -{
    1.25 -	void *ptr = malloc(size);
    1.26 -	if (ptr)
    1.27 -		return ptr;
    1.28 -	barf("malloc of %zu failed", size);
    1.29 -}
    1.30 -
    1.31 -/* This version adds one byte (for nul term) */
    1.32 -void *grab_file(const char *filename, unsigned long *size)
    1.33 -{
    1.34 -	unsigned int max = 16384;
    1.35 -	int ret, fd;
    1.36 -	void *buffer;
    1.37 -
    1.38 -	if (streq(filename, "-"))
    1.39 -		fd = dup(STDIN_FILENO);
    1.40 -	else
    1.41 -		fd = open(filename, O_RDONLY, 0);
    1.42 -
    1.43 -	if (fd == -1)
    1.44 -		return NULL;
    1.45 -
    1.46 -	buffer = malloc(max+1);
    1.47 -	if (!buffer)
    1.48 -		goto error;
    1.49 -	*size = 0;
    1.50 -	while ((ret = read(fd, buffer + *size, max - *size)) > 0) {
    1.51 -		*size += ret;
    1.52 -		if (*size == max) {
    1.53 -			void *nbuffer;
    1.54 -			max *= 2;
    1.55 -			nbuffer = realloc(buffer, max + 1);
    1.56 -			if (!nbuffer)
    1.57 -				goto error;
    1.58 -			buffer = nbuffer;
    1.59 -		}
    1.60 -	}
    1.61 -	if (ret < 0)
    1.62 -		goto error;
    1.63 -	((char *)buffer)[*size] = '\0';
    1.64 -	close(fd);
    1.65 -	return buffer;
    1.66 -error:
    1.67 -	free(buffer);
    1.68 -	close(fd);
    1.69 -	return NULL;
    1.70 -}
    1.71 -
    1.72 -void release_file(void *data, unsigned long size __attribute__((unused)))
    1.73 -{
    1.74 -	free(data);
    1.75 -}
     2.1 --- a/tools/xenstore/utils.h	Wed Aug 01 09:11:08 2007 +0100
     2.2 +++ b/tools/xenstore/utils.h	Wed Aug 01 12:05:42 2007 +0100
     2.3 @@ -21,39 +21,12 @@ static inline bool strends(const char *a
     2.4  
     2.5  #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
     2.6  
     2.7 -#define ___stringify(x)	#x
     2.8 -#define __stringify(x)		___stringify(x)
     2.9 -
    2.10 -/* Convenient wrappers for malloc and realloc.  Use them. */
    2.11 -#define new(type) ((type *)malloc_nofail(sizeof(type)))
    2.12 -#define new_array(type, num) realloc_array((type *)0, (num))
    2.13 -#define realloc_array(ptr, num) ((__typeof__(ptr))_realloc_array((ptr), sizeof((*ptr)), (num)))
    2.14 -
    2.15 -void *malloc_nofail(size_t size);
    2.16 -void *realloc_nofail(void *ptr, size_t size);
    2.17 -void *_realloc_array(void *ptr, size_t size, size_t num);
    2.18 -
    2.19  void barf(const char *fmt, ...) __attribute__((noreturn));
    2.20  void barf_perror(const char *fmt, ...) __attribute__((noreturn));
    2.21  
    2.22 -/* This version adds one byte (for nul term) */
    2.23 -void *grab_file(const char *filename, unsigned long *size);
    2.24 -void release_file(void *data, unsigned long size);
    2.25 -
    2.26 -/* Signal handling: returns fd to listen on. */
    2.27 -int signal_to_fd(int signal);
    2.28 -void close_signal(int fd);
    2.29 -
    2.30  void xprintf(const char *fmt, ...);
    2.31  
    2.32  #define eprintf(_fmt, _args...) xprintf("[ERR] %s" _fmt, __FUNCTION__, ##_args)
    2.33 -#define iprintf(_fmt, _args...) xprintf("[INF] %s" _fmt, __FUNCTION__, ##_args)
    2.34 -
    2.35 -#ifdef DEBUG
    2.36 -#define dprintf(_fmt, _args...) xprintf("[DBG] %s" _fmt, __FUNCTION__, ##_args)
    2.37 -#else
    2.38 -#define dprintf(_fmt, _args...) ((void)0)
    2.39 -#endif
    2.40  
    2.41  /*
    2.42   * Mux errno values onto returned pointers.