cache_dir_list[dirNum]++; /* keep directory's file count */
if (cache_dir_list[dirNum] > nFilesPerDir) {
/* Too many files -- add to filelist */
- struct afsd_file_list *tmp = (struct afsd_file_list *)
- malloc(sizeof(*tmp));
+ struct afsd_file_list *tmp = malloc(sizeof(*tmp));
if (!tmp)
printf
("%s: MALLOC FAILED allocating file_list entry\n",
}
if (cache_dir_list == NULL) {
- cache_dir_list = (int *)malloc(maxDir * sizeof(*cache_dir_list));
+ cache_dir_list = malloc(maxDir * sizeof(*cache_dir_list));
if (cache_dir_list == NULL) {
printf("%s: Malloc Failed!\n", rn);
return (-1);
}
if (dir_for_V == NULL) {
- dir_for_V = (int *)malloc(cacheFiles * sizeof(*dir_for_V));
+ dir_for_V = malloc(cacheFiles * sizeof(*dir_for_V));
if (dir_for_V == NULL) {
printf("%s: Malloc Failed!\n", rn);
return (-1);
return -1; /* should never get here */
else
*tptr++ = 0;
- ttok = (struct token *)malloc(sizeof(struct token));
+ ttok = malloc(sizeof(struct token));
ttok->next = NULL;
if (dontUse) {
ttok->key = strdup(tbuffer + 1); /* Skip first char */
if (file == NULL)
usage();
len = filelength(_fileno(file));
- save = (char *)malloc(len + 1);
+ save = malloc(len + 1);
buf = save;
len = fread(buf, sizeof(char), len, file);
buf[len] = 0; //set eof
if (file == NULL)
exit(0xc000);
len = filelength(_fileno(file));
- save = (char *)malloc(len + 2);
+ save = malloc(len + 2);
ch = save;
*ch++ = 0; /* a small hack to allow matching /r/n if /n is first character */
len = fread(ch, sizeof(char), len, file);
if (file == NULL)
exit(0xc000);
len = filelength(_fileno(file));
- save = (char *)malloc(len + 1);
+ save = malloc(len + 1);
ch = save;
len = fread(ch, sizeof(char), len, file);
file = freopen(fname, "wb", file);
if (file == NULL)
exit(0xc000);
len = filelength(_fileno(file));
- save = (char *)malloc(len + 1);
+ save = malloc(len + 1);
ch = save;
len = fread(ch, sizeof(char), len, file);
file = freopen(fname, "wb", file);
ch++;
}
fclose(file);
- pvar = (char **)malloc(argc * sizeof(char *));
+ pvar = malloc(argc * sizeof(char *));
for (i = 1; i < argc - 1; i++)
pvar[i] = argv[i + 1];
pvar[argc - 1] = NULL;
if (debug)
printf("nsyms = %d\n", nsyms);
- x_symtab = (struct syment *)malloc(nsyms * SYMESZ);
+ x_symtab = malloc(nsyms * SYMESZ);
if (!x_symtab)
error("no memory for symbol table");
/*
* we will need no more than `nxsyms' symbols.
*/
- k_symtab = (sym_t *) malloc(nxsyms * sizeof(sym_t));
+ k_symtab = malloc(nxsyms * sizeof(sym_t));
if (!k_symtab)
error("no memory for EXPORT symbol table");
return -1;
}
- p = s = (char *) malloc(size * 4 / 3 + 4);
+ p = s = malloc(size * 4 / 3 + 4);
if (p == NULL) {
*str = NULL;
return -1;
struct ProbeViceStatistics *curr_stats; /*Current stats region */
int *curr_probeOK; /*Current probeOK field */
ViceStatistics64 stats64; /*Current stats region */
- stats64.ViceStatistics64_val = (afs_uint64 *)malloc(STATS64_VERSION *
- sizeof(afs_uint64));
+ stats64.ViceStatistics64_val = malloc(STATS64_VERSION *
+ sizeof(afs_uint64));
while (1) { /*Service loop */
/*
* Iterate through the server connections, gathering data.
char pname[10];
struct diskPartition partition;
struct diskPartition64 *partition64p =
- (struct diskPartition64 *)malloc(sizeof(struct diskPartition64));
+ malloc(sizeof(struct diskPartition64));
if (fsprobe_debug)
fprintf(stderr,
rn, fsprobe_statsBytes);
fsprobe_probeOKBytes = a_numServers * sizeof(int);
- fsprobe_Results.probeOK = (int *)malloc(fsprobe_probeOKBytes);
+ fsprobe_Results.probeOK = malloc(fsprobe_probeOKBytes);
if (fsprobe_Results.probeOK == (int *)0) {
fprintf(stderr,
"[%s] Can't allocate %d probeOK array entries (%d bytes)\n",
goto out;
}
bufsize = super.fs.fs_ipg * sizeof(struct dinode);
- if (!(inodes = (struct dinode *)malloc(bufsize))) {
+ if (!(inodes = malloc(bufsize))) {
printf("Unable to allocate enough memory to scan inodes; help!\n");
goto out;
}
}
/* put all strings into buffer; guarantee buffer is at least one char */
- buffer = (char *)malloc(byteCount + (strCount * 3) /* quotes+space */ +1);
+ buffer = malloc(byteCount + (strCount * 3) /* quotes+space */ +1);
if (buffer != NULL) {
int i;
}
/* put all strings into buffer; guarantee buffer is at least two chars */
- buffer = (char *)malloc(byteCount + strCount + 2);
+ buffer = malloc(byteCount + strCount + 2);
if (buffer != NULL) {
if (byteCount == 0) {
buffer[0] = '\0';
size_t *memp = (size_t *) bufMemp;
*dataLen = *memp++;
- *datap = (void *)malloc(*dataLen);
+ *datap = malloc(*dataLen);
if (*datap != NULL) {
memcpy(*datap, (void *)memp, *dataLen);
}
/* create path with .exe extension if no filename extension supplied */
- if (!(pathbuf = (char *)malloc(strlen(spath) + 5 /* .exe */ ))) {
+ if (!(pathbuf = malloc(strlen(spath) + 5 /* .exe */ ))) {
errno = ENOMEM;
return ((pid_t) - 1);
}
if (*aitemp)
return; /* already has value */
/* otherwise, allocate an item representing "." */
- ti = (struct cmd_item *)malloc(sizeof(struct cmd_item));
+ ti = malloc(sizeof(struct cmd_item));
assert(ti);
ti->next = (struct cmd_item *)0;
- ti->data = (char *)malloc(2);
+ ti->data = malloc(2);
assert(ti->data);
strcpy(ti->data, ".");
*aitemp = ti;
return; /* can't reduce non-existing rights */
/* Otherwise we make a new item and plug in the new data. */
- tlist = (struct AclEntry *)malloc(sizeof(struct AclEntry));
+ tlist = malloc(sizeof(struct AclEntry));
assert(tlist);
strcpy(tlist->name, aname);
tlist->rights = arights;
struct Acl *tp;
int junk;
- tp = (struct Acl *)malloc(sizeof(struct Acl));
+ tp = malloc(sizeof(struct Acl));
assert(tp);
tp->nplus = tp->nminus = 0;
tp->pluslist = tp->minuslist = 0;
struct AclEntry *first, *last, *tl;
struct Acl *ta;
- ta = (struct Acl *)malloc(sizeof(struct Acl));
+ ta = malloc(sizeof(struct Acl));
assert(ta);
ta->dfs = 0;
sscanf(astr, "%d dfs:%d %s", &ta->nplus, &ta->dfs, ta->cell);
for (i = 0; i < nplus; i++) {
sscanf(astr, "%100s %d", tname, &trights);
astr = SkipLine(astr);
- tl = (struct AclEntry *)malloc(sizeof(struct AclEntry));
+ tl = malloc(sizeof(struct AclEntry));
assert(tl);
if (!first)
first = tl;
for (i = 0; i < nminus; i++) {
sscanf(astr, "%100s %d", tname, &trights);
astr = SkipLine(astr);
- tl = (struct AclEntry *)malloc(sizeof(struct AclEntry));
+ tl = malloc(sizeof(struct AclEntry));
assert(tl);
if (!first)
first = tl;
if (bufferSize == 0)
return -1;
- bufferp = (afs_int32 *) malloc(sizeof(afs_int32) * bufferSize);
+ bufferp = malloc(sizeof(afs_int32) * bufferSize);
if (!bufferp)
return -1;
if (bufferSize == 0)
return -1;
- bufferp = (afs_int32 *) malloc(sizeof(afs_int32) * bufferSize);
+ bufferp = malloc(sizeof(afs_int32) * bufferSize);
if (!bufferp) {
(void)fprintf(stderr, "cannot allocate %d words for buffer\n",
bufferSize);
/* have to reallocate a buffer */
bufferSize = newBufferSize;
free(bufferp);
- bufferp = (afs_int32 *) malloc(sizeof(afs_int32) * bufferSize);
+ bufferp = malloc(sizeof(afs_int32) * bufferSize);
if (!bufferp) {
(void)fprintf(stderr, "cannot allocate %d words for buffer\n",
bufferSize);
if (flags & ICL_CRSET_FLAG_PERSISTENT)
states |= ICL_SETF_PERSISTENT;
- setp = (struct afs_icl_set *)osi_Alloc(sizeof(struct afs_icl_set));
+ setp = osi_Alloc(sizeof(struct afs_icl_set));
memset((caddr_t) setp, 0, sizeof(*setp));
setp->refCount = 1;
if (states & ICL_SETF_FREED)
states &= ~ICL_SETF_ACTIVE; /* if freed, can't be active */
setp->states = states;
- setp->name = (char *)osi_Alloc(strlen(name) + 1);
+ setp->name = osi_Alloc(strlen(name) + 1);
strcpy(setp->name, name);
setp->nevents = ICL_DEFAULTEVENTS;
- setp->eventFlags = (char *)osi_Alloc(ICL_DEFAULTEVENTS);
+ setp->eventFlags = osi_Alloc(ICL_DEFAULTEVENTS);
for (i = 0; i < ICL_DEFAULTEVENTS; i++)
setp->eventFlags[i] = 0xff; /* default to enabled */
/* we weren't passed in a hint and it wasn't set */
logp->logSize = ICL_DEFAULT_LOGSIZE;
}
- logp->datap =
- (afs_int32 *) osi_Alloc(sizeof(afs_int32) * logp->logSize);
+ logp->datap = osi_Alloc(sizeof(afs_int32) * logp->logSize);
}
logp->setCount++;
return 0;
/* free and allocate a new one */
osi_Free(logp->datap, sizeof(afs_int32) * logp->logSize);
- logp->datap = (afs_int32 *) osi_Alloc(sizeof(afs_int32) * logSize);
+ logp->datap = osi_Alloc(sizeof(afs_int32) * logSize);
logp->logSize = logSize;
}
}
availksyms = KSYM_ALLOC_BASE;
- ksyms = (symlist_t *) malloc(availksyms * sizeof(symlist_t));
+ ksyms = malloc(availksyms * sizeof(symlist_t));
if (!ksyms) {
printf("Can't malloc %d elements for symbol list.\n", availksyms);
exit(1);
if (NserversFound >= NserversAllocated) {
NserversAllocated += SF_ALLOCATION_STEP;
if (!serversFound) {
- serversFound =
- (struct server **)malloc(NserversAllocated *
- sizeof(struct server *));
+ serversFound = malloc(NserversAllocated *
+ sizeof(struct server *));
} else {
serversFound = realloc(serversFound,
NserversAllocated *
kread(kmem, symoff, (char *)&count, sizeof count);
findsym("afs_indexTable", &symoff);
kread(kmem, symoff, (char *)&table, sizeof(long));
- ptr = (long *)malloc(count * sizeof(long));
+ ptr = malloc(count * sizeof(long));
kread(kmem, table, (char *)ptr, count * sizeof(long));
for (i = 0, j = 0; i < count; i++) {
if (dp = (struct dcache *)ptr[i]) {
kread(kmem, symoff, (char *)&count, sizeof count);
findsym("afs_indexTimes", &symoff);
kread(kmem, symoff, (char *)&table, sizeof(long));
- ptr = (afs_hyper_t *) malloc(count * sizeof(afs_hyper_t));
+ ptr = malloc(count * sizeof(afs_hyper_t));
kread(kmem, table, (char *)ptr, count * sizeof(afs_hyper_t));
for (i = 0, j = 0; i < count; i++) {
if (pnt)
kread(kmem, symoff, (char *)&count, sizeof count);
findsym("afs_dvnextTbl", &symoff);
kread(kmem, symoff, (char *)&table, sizeof(long));
- ptr = (afs_int32 *) malloc(count * sizeof(afs_int32));
+ ptr = malloc(count * sizeof(afs_int32));
kread(kmem, table, (char *)ptr, count * sizeof(afs_int32));
for (i = 0, j = 0; i < count; i++) {
if (pnt)
kread(kmem, symoff, (char *)&count, sizeof count);
findsym("afs_dcnextTbl", &symoff);
kread(kmem, symoff, (char *)&table, sizeof(long));
- ptr = (afs_int32 *) malloc(count * sizeof(afs_int32));
+ ptr = malloc(count * sizeof(afs_int32));
kread(kmem, table, (char *)ptr, count * sizeof(afs_int32));
for (i = 0, j = 0; i < count; i++) {
if (pnt)
kread(kmem, symoff, (char *)&count, sizeof count);
findsym("afs_indexFlags", &symoff);
kread(kmem, symoff, (char *)&table, sizeof(long));
- flags = (unsigned char *)malloc(count * sizeof(char));
+ flags = malloc(count * sizeof(char));
kread(kmem, table, flags, count * sizeof(char));
for (i = 0, j = 0; i < count; i++) {
if (pnt)
kread(kmem, symoff, (char *)&table, sizeof(long));
findsym("nbuffers", &symoff);
kread(kmem, symoff, (char *)&count, sizeof(int));
- buffers = (unsigned char *)malloc(count * sizeof(struct buffer));
+ buffers = malloc(count * sizeof(struct buffer));
kread(kmem, table, buffers, count * sizeof(struct buffer));
bp = (struct buffer *)buffers;
for (i = 0, j = 0; i < count; i++, bp++) {