mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-05-31 00:30:57 +00:00
Fix a pile of sizeof goofs.
While scan-build wasn't what I was looking for, it has proven useful anyway: many of the sizeof errors were just noise, but a few were actual bugs (allocating too much or too little memory).
This commit is contained in:
parent
575a67b2a1
commit
8fd5be0ee0
15 changed files with 16 additions and 16 deletions
|
@ -102,7 +102,7 @@ filelist_print (filelist_t *filelist)
|
|||
if (filelist->count) {
|
||||
qsort (filelist->list, filelist->count, sizeof (char *), filelist_cmp);
|
||||
|
||||
list = malloc ((filelist->count + 1) * sizeof (char **));
|
||||
list = malloc ((filelist->count + 1) * sizeof (char *));
|
||||
list[filelist->count] = 0;
|
||||
for (i = 0; i < filelist->count; i++)
|
||||
list[i] = filelist->list[i];
|
||||
|
|
|
@ -108,7 +108,7 @@ source_path_f (cvar_t *var)
|
|||
for (i = 2, s = source_path_string; *s; s++)
|
||||
if (*s == ';')
|
||||
i++;
|
||||
source_paths = malloc (i * sizeof (char **));
|
||||
source_paths = malloc (i * sizeof (char *));
|
||||
source_paths[0] = source_path_string;
|
||||
for (i = 1, s = source_path_string; *s; s++)
|
||||
if (*s == ';') {
|
||||
|
|
|
@ -445,7 +445,7 @@ ObjectHash_Get_f (gib_object_t *obj, gib_method_t *method, void *data,
|
|||
if ((refs = (ObjRef_t **) Hash_FindList (objh->objects,
|
||||
mesg.argv[1]))) {
|
||||
for (r = refs, len = 0; *r; r++, len++);
|
||||
reply = malloc (sizeof (char **) * len);
|
||||
reply = malloc (sizeof (char *) * len);
|
||||
for (r = refs, i = 0; *r; r++, i++)
|
||||
reply[i] = (*r)->obj->handstr;
|
||||
GIB_Reply (obj, mesg, len, reply);
|
||||
|
|
|
@ -51,7 +51,7 @@ GIB_Var_New (const char *key)
|
|||
{
|
||||
gib_var_t *new = calloc (1, sizeof (gib_var_t));
|
||||
|
||||
new->array = calloc (1, sizeof (dstring_t *));
|
||||
new->array = calloc (1, sizeof (struct gib_varray_s));
|
||||
new->key = strdup (key);
|
||||
return new;
|
||||
}
|
||||
|
|
|
@ -153,7 +153,7 @@ sw_iqm_load_textures (iqm_t *iqm)
|
|||
bytes = (iqm->num_verts + 7) / 8;
|
||||
done_verts = alloca (bytes);
|
||||
memset (done_verts, 0, bytes);
|
||||
sw->skins = malloc (iqm->num_meshes * sizeof (tex_t));
|
||||
sw->skins = malloc (iqm->num_meshes * sizeof (tex_t *));
|
||||
for (i = 0; i < iqm->num_meshes; i++) {
|
||||
for (j = 0; j < i; j++) {
|
||||
if (iqm->meshes[j].material == iqm->meshes[i].material) {
|
||||
|
|
|
@ -100,7 +100,7 @@ COM_InitArgv (int argc, const char **argv)
|
|||
safe = false;
|
||||
|
||||
largv = (const char **) calloc (1, (argc + NUM_SAFE_ARGVS + 1) *
|
||||
sizeof (const char **));
|
||||
sizeof (const char *));
|
||||
|
||||
for (com_argc = 0, len = 0; com_argc < argc; com_argc++) {
|
||||
largv[com_argc] = argv[com_argc];
|
||||
|
|
|
@ -161,7 +161,7 @@ read_adtl (dstring_t *list_buf, QFile *f, int len)
|
|||
chunk = &label->ck;
|
||||
break;
|
||||
default:
|
||||
data = malloc (sizeof (data));
|
||||
data = malloc (sizeof (riff_data_t));
|
||||
data->ck = ck;
|
||||
data->data = read_data (f, ck.len);
|
||||
chunk = &data->ck;
|
||||
|
|
|
@ -150,8 +150,8 @@ VID_MakeColormap16 (void *outcolormap, byte *pal)
|
|||
void
|
||||
VID_MakeColormaps (void)
|
||||
{
|
||||
vid.colormap16 = malloc (256*VID_GRADES * sizeof (short));
|
||||
vid.colormap32 = malloc (256*VID_GRADES * sizeof (int));
|
||||
vid.colormap16 = malloc (256*VID_GRADES * sizeof (unsigned short));
|
||||
vid.colormap32 = malloc (256*VID_GRADES * sizeof (unsigned int));
|
||||
SYS_CHECKMEM (vid.colormap16 && vid.colormap32);
|
||||
VID_MakeColormap16(vid.colormap16, vid.palette);
|
||||
VID_MakeColormap32(vid.colormap32, vid.palette);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue