support.c (140072) | support.c (201217) |
---|---|
1/* 2 * Generic "support" routines to replace those obtained from libiberty for ld. 3 * 4 * I've collected these from random bits of (published) code I've written 5 * over the years, not that they are a big deal. peter@freebsd.org 6 *- 7 * Copyright (C) 1996 8 * Peter Wemm. All rights reserved. --- 14 unchanged lines hidden (view full) --- 23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29 * SUCH DAMAGE. 30 *- | 1/* 2 * Generic "support" routines to replace those obtained from libiberty for ld. 3 * 4 * I've collected these from random bits of (published) code I've written 5 * over the years, not that they are a big deal. peter@freebsd.org 6 *- 7 * Copyright (C) 1996 8 * Peter Wemm. All rights reserved. --- 14 unchanged lines hidden (view full) --- 23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29 * SUCH DAMAGE. 30 *- |
31 * $FreeBSD: head/libexec/rtld-aout/support.c 140072 2005-01-11 16:40:29Z trhodes $ | 31 * $FreeBSD: head/libexec/rtld-aout/support.c 201217 2009-12-29 21:07:17Z ed $ |
32 */ 33#include <sys/types.h> 34#include <string.h> 35#include <stdlib.h> 36#include <err.h> 37 38#include "support.h" 39 40char * | 32 */ 33#include <sys/types.h> 34#include <string.h> 35#include <stdlib.h> 36#include <err.h> 37 38#include "support.h" 39 40char * |
41concat(s1, s2, s3) 42 const char *s1, *s2, *s3; | 41concat(const char *s1, const char *s2, const char *s3) |
43{ 44 int len = 1; 45 char *s; 46 if (s1) 47 len += strlen(s1); 48 if (s2) 49 len += strlen(s2); 50 if (s3) --- 5 unchanged lines hidden (view full) --- 56 if (s2) 57 strcat(s, s2); 58 if (s3) 59 strcat(s, s3); 60 return s; 61} 62 63void * | 42{ 43 int len = 1; 44 char *s; 45 if (s1) 46 len += strlen(s1); 47 if (s2) 48 len += strlen(s2); 49 if (s3) --- 5 unchanged lines hidden (view full) --- 55 if (s2) 56 strcat(s, s2); 57 if (s3) 58 strcat(s, s3); 59 return s; 60} 61 62void * |
64xmalloc(n) 65 size_t n; | 63xmalloc(size_t n) |
66{ 67 char *p = malloc(n); 68 69 if (p == NULL) 70 errx(1, "Could not allocate memory"); 71 72 return p; 73} 74 75void * | 64{ 65 char *p = malloc(n); 66 67 if (p == NULL) 68 errx(1, "Could not allocate memory"); 69 70 return p; 71} 72 73void * |
76xrealloc(p, n) 77 void *p; 78 size_t n; | 74xrealloc(void *p, size_t n) |
79{ 80 p = realloc(p, n); 81 82 if (p == NULL) 83 errx(1, "Could not allocate memory"); 84 85 return p; 86} | 75{ 76 p = realloc(p, n); 77 78 if (p == NULL) 79 errx(1, "Could not allocate memory"); 80 81 return p; 82} |