Mercurial > dropbear
comparison scpmisc.c @ 299:740e782679be ucc-axis-hack
Various changes to compile+kind of run on UCC's axis board.
Note that fprintf(stdin -> printf( accounts for many of the changes
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Sat, 25 Mar 2006 12:57:09 +0000 |
parents | 5c6f9d27ea1c |
children | 973fccb59ea4 |
comparison
equal
deleted
inserted
replaced
266:e37b160c414c | 299:740e782679be |
---|---|
47 xmalloc(size_t size) | 47 xmalloc(size_t size) |
48 { | 48 { |
49 void *ptr; | 49 void *ptr; |
50 | 50 |
51 if (size == 0) { | 51 if (size == 0) { |
52 fprintf(stderr, "xmalloc: zero size\n"); | 52 printf( "xmalloc: zero size\n"); |
53 exit(EXIT_FAILURE); | 53 exit(EXIT_FAILURE); |
54 } | 54 } |
55 ptr = malloc(size); | 55 ptr = malloc(size); |
56 if (ptr == NULL) { | 56 if (ptr == NULL) { |
57 fprintf(stderr, "xmalloc: out of memory (allocating %lu bytes)\n", (u_long) size); | 57 printf( "xmalloc: out of memory (allocating %lu bytes)\n", (u_long) size); |
58 exit(EXIT_FAILURE); | 58 exit(EXIT_FAILURE); |
59 } | 59 } |
60 return ptr; | 60 return ptr; |
61 } | 61 } |
62 | 62 |
64 xrealloc(void *ptr, size_t new_size) | 64 xrealloc(void *ptr, size_t new_size) |
65 { | 65 { |
66 void *new_ptr; | 66 void *new_ptr; |
67 | 67 |
68 if (new_size == 0) { | 68 if (new_size == 0) { |
69 fprintf(stderr, "xrealloc: zero size\n"); | 69 printf( "xrealloc: zero size\n"); |
70 exit(EXIT_FAILURE); | 70 exit(EXIT_FAILURE); |
71 } | 71 } |
72 if (ptr == NULL) | 72 if (ptr == NULL) |
73 new_ptr = malloc(new_size); | 73 new_ptr = malloc(new_size); |
74 else | 74 else |
75 new_ptr = realloc(ptr, new_size); | 75 new_ptr = realloc(ptr, new_size); |
76 if (new_ptr == NULL) { | 76 if (new_ptr == NULL) { |
77 fprintf(stderr, "xrealloc: out of memory (new_size %lu bytes)\n", (u_long) new_size); | 77 printf( "xrealloc: out of memory (new_size %lu bytes)\n", (u_long) new_size); |
78 exit(EXIT_FAILURE); | 78 exit(EXIT_FAILURE); |
79 } | 79 } |
80 return new_ptr; | 80 return new_ptr; |
81 } | 81 } |
82 | 82 |
83 void | 83 void |
84 xfree(void *ptr) | 84 xfree(void *ptr) |
85 { | 85 { |
86 if (ptr == NULL) { | 86 if (ptr == NULL) { |
87 fprintf(stderr, "xfree: NULL pointer given as argument\n"); | 87 printf( "xfree: NULL pointer given as argument\n"); |
88 exit(EXIT_FAILURE); | 88 exit(EXIT_FAILURE); |
89 } | 89 } |
90 free(ptr); | 90 free(ptr); |
91 } | 91 } |
92 | 92 |