#endif
#endif
+#include "xalloc.h"
#include "nls.h"
/* Until it gets put in the kernel,
toggle by hand. */
/* query stuff after this line */
- cmon = (struct cyclades_control *) malloc(sizeof (struct cyclades_control)
- * numfiles);
- if(!cmon) {
- perror(_("malloc failed"));
- exit(1);
- }
+ cmon = xmalloc(sizeof(struct cyclades_control) * numfiles);
+
if(signal(SIGINT, summary)||
signal(SIGQUIT, summary)||
signal(SIGTERM, summary)) {
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/utsname.h>
+
+#include "xalloc.h"
#include "nls.h"
#define S_LEN 128
static char defaultpro[]="/proc/profile";
static char optstring[]="M:m:np:itvarVbs";
-static void *
-xmalloc (size_t size) {
- void *t;
-
- if (size == 0)
- return NULL;
-
- t = malloc (size);
- if (t == NULL) {
- fprintf(stderr, _("out of memory"));
- exit(1);
- }
-
- return t;
-}
-
static FILE *
myopen(char *name, char *mode, int *flag) {
int len = strlen(name);
exit(1);
}
- if (!(buf=malloc(len))) {
- fprintf(stderr,"%s: malloc(): %s\n", prgname, strerror(errno));
- exit(1);
- }
+ buf = xmalloc(len);
if (read(proFd,buf,len) != len) {
fprintf(stderr,"%s: %s: %s\n",prgname,proFile,strerror(errno));
#include <stdlib.h>
#include <string.h>
#include <errno.h>
+
#include "lp.h"
+#include "xalloc.h"
#include "nls.h"
struct command {
printf(_("%s (%s)\n"), progname, PACKAGE_STRING);
}
-static void *
-mylloc(long size) {
- void *ptr;
- if(!(ptr = (void*)malloc(size))) {
- perror(_("malloc error"));
- exit(2);
- }
- return ptr;
-}
-
static char *progname;
static long
if (argc < 2) print_usage(progname);
- cmdst = cmds = mylloc(sizeof(struct command));
+ cmdst = cmds = xmalloc(sizeof(struct command));
cmds->next = 0;
show_irq = 1;
case 'i':
cmds->op = LPSETIRQ;
cmds->val = get_val(optarg);
- cmds->next = mylloc(sizeof(struct command));
+ cmds->next = xmalloc(sizeof(struct command));
cmds = cmds->next; cmds->next = 0;
break;
case 't':
cmds->op = LPTIME;
cmds->val = get_val(optarg);
- cmds->next = mylloc(sizeof(struct command));
+ cmds->next = xmalloc(sizeof(struct command));
cmds = cmds->next; cmds->next = 0;
break;
case 'c':
cmds->op = LPCHAR;
cmds->val = get_val(optarg);
- cmds->next = mylloc(sizeof(struct command));
+ cmds->next = xmalloc(sizeof(struct command));
cmds = cmds->next; cmds->next = 0;
break;
case 'w':
cmds->op = LPWAIT;
cmds->val = get_val(optarg);
- cmds->next = mylloc(sizeof(struct command));
+ cmds->next = xmalloc(sizeof(struct command));
cmds = cmds->next; cmds->next = 0;
break;
case 'a':
cmds->op = LPABORT;
cmds->val = get_onoff(optarg);
- cmds->next = mylloc(sizeof(struct command));
+ cmds->next = xmalloc(sizeof(struct command));
cmds = cmds->next; cmds->next = 0;
break;
case 'q':
case 'o':
cmds->op = LPABORTOPEN;
cmds->val = get_onoff(optarg);
- cmds->next = mylloc(sizeof(struct command));
+ cmds->next = xmalloc(sizeof(struct command));
cmds = cmds->next; cmds->next = 0;
break;
case 'C':
cmds->op = LPCAREFUL;
cmds->val = get_onoff(optarg);
- cmds->next = mylloc(sizeof(struct command));
+ cmds->next = xmalloc(sizeof(struct command));
cmds = cmds->next; cmds->next = 0;
break;
case 's':
show_irq = 0;
cmds->op = LPGETSTATUS;
cmds->val = 0;
- cmds->next = mylloc(sizeof(struct command));
+ cmds->next = xmalloc(sizeof(struct command));
cmds = cmds->next; cmds->next = 0;
break;
#endif
case 'r':
cmds->op = LPRESET;
cmds->val = 0;
- cmds->next = mylloc(sizeof(struct command));
+ cmds->next = xmalloc(sizeof(struct command));
cmds = cmds->next; cmds->next = 0;
break;
#endif
/* Note: this will do the wrong thing on 2.0.36 when compiled under 2.2.x */
cmds->op = LPTRUSTIRQ;
cmds->val = get_onoff(optarg);
- cmds->next = mylloc(sizeof(struct command));
+ cmds->next = xmalloc(sizeof(struct command));
cmds = cmds->next; cmds->next = 0;
break;
#endif