Changed all malloc() to calloc()
This commit is contained in:
parent
15266fb310
commit
2a48b34bcd
@ -1 +1 @@
|
||||
#define Cdrskin_timestamP "2010.07.12.193201"
|
||||
#define Cdrskin_timestamP "2010.07.12.193644"
|
||||
|
@ -143,7 +143,7 @@ static void add_worker(int w_type, struct burn_drive *d,
|
||||
pthread_attr_t attr;
|
||||
#endif
|
||||
|
||||
a = malloc(sizeof(struct w_list));
|
||||
a = calloc(1, sizeof(struct w_list));
|
||||
a->w_type = w_type;
|
||||
a->drive = d;
|
||||
a->u = *(union w_list_data *)data;
|
||||
|
@ -12,9 +12,6 @@
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
/* #include <m alloc.h> ts A61013 : not in GNU/Linux man 3 malloc */
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <signal.h>
|
||||
@ -1297,7 +1294,7 @@ int burn_drive_add_whitelist(char *device_address)
|
||||
if(enumeration_whitelist_top+1 >= BURN_DRIVE_WHITELIST_LEN)
|
||||
return 0;
|
||||
enumeration_whitelist_top++;
|
||||
new_item = malloc(strlen(device_address) + 1);
|
||||
new_item = calloc(1, strlen(device_address) + 1);
|
||||
if (new_item == NULL)
|
||||
return -1;
|
||||
strcpy(new_item, device_address);
|
||||
@ -2221,7 +2218,7 @@ int burn_speed_descriptor_new(struct burn_speed_descriptor **s,
|
||||
{
|
||||
struct burn_speed_descriptor *o;
|
||||
|
||||
(*s) = o = malloc(sizeof(struct burn_speed_descriptor));
|
||||
(*s) = o = calloc(1, sizeof(struct burn_speed_descriptor));
|
||||
if (o == NULL)
|
||||
return -1;
|
||||
o->source = 0;
|
||||
@ -2392,7 +2389,7 @@ int burn_disc_get_multi_caps(struct burn_drive *d, enum burn_write_types wt,
|
||||
if(s == BURN_DISC_UNGRABBED)
|
||||
return -1;
|
||||
*caps = o = (struct burn_multi_caps *)
|
||||
malloc(sizeof(struct burn_multi_caps));
|
||||
calloc(1, sizeof(struct burn_multi_caps));
|
||||
if(*caps == NULL)
|
||||
return -1;
|
||||
/* Default says nothing is available */
|
||||
|
@ -129,7 +129,7 @@ struct burn_source *burn_file_source_new(const char *path, const char *subpath)
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
fs = malloc(sizeof(struct burn_source_file));
|
||||
fs = calloc(1, sizeof(struct burn_source_file));
|
||||
|
||||
/* ts A70825 */
|
||||
if (fs == NULL) {
|
||||
@ -175,7 +175,7 @@ struct burn_source *burn_fd_source_new(int datafd, int subfd, off_t size)
|
||||
|
||||
if (datafd == -1)
|
||||
return NULL;
|
||||
fs = malloc(sizeof(struct burn_source_file));
|
||||
fs = calloc(1, sizeof(struct burn_source_file));
|
||||
if (fs == NULL) /* ts A70825 */
|
||||
return NULL;
|
||||
fs->datafd = datafd;
|
||||
@ -508,7 +508,7 @@ struct burn_source *burn_fifo_source_new(struct burn_source *inp,
|
||||
"Desired fifo buffer too small", 0, 0);
|
||||
return NULL;
|
||||
}
|
||||
fs = malloc(sizeof(struct burn_source_fifo));
|
||||
fs = calloc(1, sizeof(struct burn_source_fifo));
|
||||
if (fs == NULL)
|
||||
return NULL;
|
||||
fs->is_started = 0;
|
||||
|
@ -35,7 +35,7 @@ int libdax_audioxtr_new(struct libdax_audioxtr **xtr, char *path, int flag)
|
||||
int ret= -1;
|
||||
struct libdax_audioxtr *o;
|
||||
|
||||
o= *xtr= (struct libdax_audioxtr *) malloc(sizeof(struct libdax_audioxtr));
|
||||
o= *xtr= (struct libdax_audioxtr *) calloc(1, sizeof(struct libdax_audioxtr));
|
||||
if(o==NULL)
|
||||
return(-1);
|
||||
strncpy(o->path,path,LIBDAX_AUDIOXTR_STRLEN-1);
|
||||
|
@ -37,7 +37,7 @@ static int libdax_msgs_item_new(struct libdax_msgs_item **item,
|
||||
struct timezone tz;
|
||||
|
||||
(*item)= o=
|
||||
(struct libdax_msgs_item *) malloc(sizeof(struct libdax_msgs_item));
|
||||
(struct libdax_msgs_item *) calloc(1, sizeof(struct libdax_msgs_item));
|
||||
if(o==NULL)
|
||||
return(-1);
|
||||
o->timestamp= 0.0;
|
||||
@ -140,7 +140,7 @@ int libdax_msgs_new(struct libdax_msgs **m, int flag)
|
||||
{
|
||||
struct libdax_msgs *o;
|
||||
|
||||
(*m)= o= (struct libdax_msgs *) malloc(sizeof(struct libdax_msgs));
|
||||
(*m)= o= (struct libdax_msgs *) calloc(1, sizeof(struct libdax_msgs));
|
||||
if(o==NULL)
|
||||
return(-1);
|
||||
o->refcount= 1;
|
||||
@ -370,7 +370,7 @@ int libdax_msgs_submit(struct libdax_msgs *m, int origin, int error_code,
|
||||
item->severity= severity;
|
||||
item->priority= priority;
|
||||
if(msg_text!=NULL) {
|
||||
item->msg_text= malloc(strlen(msg_text)+1);
|
||||
item->msg_text= calloc(1, strlen(msg_text)+1);
|
||||
if(item->msg_text==NULL)
|
||||
goto failed;
|
||||
strcpy(item->msg_text,msg_text);
|
||||
|
@ -1165,7 +1165,7 @@ int mmc_fake_toc(struct burn_drive *d)
|
||||
if (d->disc == NULL)
|
||||
return -1;
|
||||
d->toc_entries = d->last_track_no + d->complete_sessions;
|
||||
d->toc_entry = malloc(d->toc_entries * sizeof(struct burn_toc_entry));
|
||||
d->toc_entry = calloc(d->toc_entries, sizeof(struct burn_toc_entry));
|
||||
if (d->toc_entry == NULL)
|
||||
return -1;
|
||||
memset(d->toc_entry, 0,d->toc_entries * sizeof(struct burn_toc_entry));
|
||||
|
@ -24,7 +24,7 @@ struct burn_source *burn_null_source_new(void)
|
||||
{
|
||||
struct burn_source *src;
|
||||
|
||||
src = malloc(sizeof(struct burn_source));
|
||||
src = calloc(1, sizeof(struct burn_source));
|
||||
src->refcount = 1;
|
||||
src->read = null_read;
|
||||
src->read_sub = NULL;
|
||||
|
@ -27,7 +27,7 @@ struct burn_write_opts *burn_write_opts_new(struct burn_drive *drive)
|
||||
{
|
||||
struct burn_write_opts *opts;
|
||||
|
||||
opts = malloc(sizeof(struct burn_write_opts));
|
||||
opts = calloc(1, sizeof(struct burn_write_opts));
|
||||
if (opts == NULL) {
|
||||
libdax_msgs_submit(libdax_messenger, -1, 0x00020111,
|
||||
LIBDAX_MSGS_SEV_FATAL, LIBDAX_MSGS_PRIO_HIGH,
|
||||
@ -68,7 +68,7 @@ struct burn_read_opts *burn_read_opts_new(struct burn_drive *drive)
|
||||
{
|
||||
struct burn_read_opts *opts;
|
||||
|
||||
opts = malloc(sizeof(struct burn_read_opts));
|
||||
opts = calloc(1, sizeof(struct burn_read_opts));
|
||||
opts->drive = drive;
|
||||
opts->refcount = 1;
|
||||
opts->raw = 0;
|
||||
@ -125,7 +125,7 @@ void burn_write_opts_set_toc_entries(struct burn_write_opts *opts, int count,
|
||||
struct burn_toc_entry *toc_entries)
|
||||
{
|
||||
opts->toc_entries = count;
|
||||
opts->toc_entry = malloc(count * sizeof(struct burn_toc_entry));
|
||||
opts->toc_entry = calloc(count, sizeof(struct burn_toc_entry));
|
||||
memcpy(opts->toc_entry, &toc_entries,
|
||||
sizeof(struct burn_toc_entry) * count);
|
||||
}
|
||||
|
@ -9,9 +9,6 @@
|
||||
#include "../config.h"
|
||||
#endif
|
||||
|
||||
|
||||
/* #include <m alloc.h> ts A61013 : not in GNU/Linux man 3 malloc */
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <signal.h>
|
||||
|
@ -169,9 +169,10 @@ static int sg_init_enumerator(burn_drive_enumerator_t *idx)
|
||||
idx->ccb.ccb_h.func_code = XPT_DEV_MATCH;
|
||||
idx->bufsize = sizeof(struct dev_match_result) * 100;
|
||||
idx->ccb.cdm.match_buf_len = idx->bufsize;
|
||||
idx->ccb.cdm.matches = (struct dev_match_result *)malloc(idx->bufsize);
|
||||
idx->ccb.cdm.matches = (struct dev_match_result *)
|
||||
calloc(1, idx->bufsize);
|
||||
if (idx->ccb.cdm.matches == NULL) {
|
||||
warnx("can't malloc memory for matches");
|
||||
warnx("cannot allocate memory for matches");
|
||||
close(idx->fd);
|
||||
return -1;
|
||||
}
|
||||
|
@ -160,15 +160,15 @@ static int sg_init_enumerator(burn_drive_enumerator_t *idx_)
|
||||
struct burn_drive_enumeration_state *idx;
|
||||
int bufsize;
|
||||
|
||||
idx = malloc(sizeof(*idx));
|
||||
idx = calloc(1, sizeof(*idx));
|
||||
if (idx == NULL) {
|
||||
warnx("can't malloc memory for enumerator");
|
||||
warnx("cannot allocate memory for enumerator");
|
||||
return -1;
|
||||
}
|
||||
idx->skip_device = 0;
|
||||
|
||||
if ((idx->fd = open(XPT_DEVICE, O_RDWR)) == -1) {
|
||||
warn("couldn't open %s", XPT_DEVICE);
|
||||
warn("could not open %s", XPT_DEVICE);
|
||||
free(idx);
|
||||
idx = NULL;
|
||||
return -1;
|
||||
@ -183,9 +183,9 @@ static int sg_init_enumerator(burn_drive_enumerator_t *idx_)
|
||||
idx->ccb.ccb_h.func_code = XPT_DEV_MATCH;
|
||||
bufsize = sizeof(struct dev_match_result) * 100;
|
||||
idx->ccb.cdm.match_buf_len = bufsize;
|
||||
idx->ccb.cdm.matches = (struct dev_match_result *)malloc(bufsize);
|
||||
idx->ccb.cdm.matches = (struct dev_match_result *) calloc(1, bufsize);
|
||||
if (idx->ccb.cdm.matches == NULL) {
|
||||
warnx("can't malloc memory for matches");
|
||||
warnx("cannot allocate memory for matches");
|
||||
close(idx->fd);
|
||||
free(idx);
|
||||
return -1;
|
||||
@ -487,9 +487,9 @@ static void enumerate_common(char *fname, int bus_no, int host_no,
|
||||
out.close_session = mmc_close_session;
|
||||
out.close_track_session = mmc_close;
|
||||
out.read_buffer_capacity = mmc_read_buffer_capacity;
|
||||
out.idata = malloc(sizeof(struct burn_scsi_inquiry_data));
|
||||
out.idata = calloc(1, sizeof(struct burn_scsi_inquiry_data));
|
||||
out.idata->valid = 0;
|
||||
out.mdata = malloc(sizeof(struct scsi_mode_data));
|
||||
out.mdata = calloc(1, sizeof(struct scsi_mode_data));
|
||||
out.mdata->valid = 0;
|
||||
if (out.idata == NULL || out.mdata == NULL) {
|
||||
libdax_msgs_submit(libdax_messenger, -1, 0x00020108,
|
||||
|
@ -34,7 +34,7 @@ char *burn_strdup(char *s)
|
||||
return NULL;
|
||||
|
||||
l = strlen(s) + 1;
|
||||
ret = malloc(l);
|
||||
ret = calloc(1, l);
|
||||
memcpy(ret, s, l);
|
||||
|
||||
return ret;
|
||||
@ -52,7 +52,7 @@ char *burn_strndup(char *s, int n)
|
||||
return NULL;
|
||||
|
||||
l = strlen(s);
|
||||
ret = malloc(l < n ? l : n);
|
||||
ret = calloc(1, l < n ? l : n);
|
||||
|
||||
memcpy(ret, s, l < n - 1 ? l : n - 1);
|
||||
ret[n - 1] = '\0';
|
||||
|
Loading…
Reference in New Issue
Block a user