Code cleanup: use 'const' for arrays (blenloader, gpu, imbuf, makesdna, modifiers, nodes)
This commit is contained in:
parent
88a0fe5f1b
commit
7ca74fc1c0
|
@ -102,8 +102,8 @@ void BLO_blendhandle_print_sizes(BlendHandle *bh, void *fp)
|
|||
if (bhead->code == ENDB)
|
||||
break;
|
||||
else {
|
||||
short *sp = fd->filesdna->structs[bhead->SDNAnr];
|
||||
char *name = fd->filesdna->types[sp[0]];
|
||||
const short *sp = fd->filesdna->structs[bhead->SDNAnr];
|
||||
const char *name = fd->filesdna->types[sp[0]];
|
||||
char buf[4];
|
||||
|
||||
buf[0] = (bhead->code >> 24) & 0xFF;
|
||||
|
@ -131,7 +131,7 @@ LinkNode *BLO_blendhandle_get_datablock_names(BlendHandle *bh, int ofblocktype,
|
|||
|
||||
for (bhead = blo_firstbhead(fd); bhead; bhead = blo_nextbhead(fd, bhead)) {
|
||||
if (bhead->code == ofblocktype) {
|
||||
char *idname = bhead_id_name(fd, bhead);
|
||||
const char *idname = bhead_id_name(fd, bhead);
|
||||
|
||||
BLI_linklist_prepend(&names, strdup(idname + 2));
|
||||
tot++;
|
||||
|
@ -156,7 +156,7 @@ LinkNode *BLO_blendhandle_get_previews(BlendHandle *bh, int ofblocktype, int *to
|
|||
|
||||
for (bhead = blo_firstbhead(fd); bhead; bhead = blo_nextbhead(fd, bhead)) {
|
||||
if (bhead->code == ofblocktype) {
|
||||
char *idname = bhead_id_name(fd, bhead);
|
||||
const char *idname = bhead_id_name(fd, bhead);
|
||||
switch (GS(idname)) {
|
||||
case ID_MA: /* fall through */
|
||||
case ID_TE: /* fall through */
|
||||
|
|
|
@ -537,7 +537,7 @@ static Main *blo_find_main(FileData *fd, const char *filepath, const char *relab
|
|||
// printf("blo_find_main: converted to %s\n", name1);
|
||||
|
||||
for (m = mainlist->first; m; m = m->next) {
|
||||
char *libname = (m->curlib) ? m->curlib->filepath : m->name;
|
||||
const char *libname = (m->curlib) ? m->curlib->filepath : m->name;
|
||||
|
||||
if (BLI_path_cmp(name1, libname) == 0) {
|
||||
if (G.debug & G_DEBUG) printf("blo_find_main: found library %s\n", libname);
|
||||
|
@ -3052,7 +3052,7 @@ static void lib_link_key(FileData *fd, Main *main)
|
|||
static void switch_endian_keyblock(Key *key, KeyBlock *kb)
|
||||
{
|
||||
int elemsize, a, b;
|
||||
char *data, *poin, *cp;
|
||||
const char *data, *poin, *cp;
|
||||
|
||||
elemsize = key->elemsize;
|
||||
data = kb->data;
|
||||
|
@ -4333,7 +4333,7 @@ static void lib_link_object(FileData *fd, Main *main)
|
|||
/* When the object is local and the data is library its possible
|
||||
* the material list size gets out of sync. [#22663] */
|
||||
if (ob->data && ob->id.lib != ((ID *)ob->data)->lib) {
|
||||
short *totcol_data = give_totcolp(ob);
|
||||
const short *totcol_data = give_totcolp(ob);
|
||||
/* Only expand so as not to loose any object materials that might be set. */
|
||||
if (totcol_data && (*totcol_data > ob->totcol)) {
|
||||
/* printf("'%s' %d -> %d\n", ob->id.name, ob->totcol, *totcol_data); */
|
||||
|
|
|
@ -1267,7 +1267,7 @@ void blo_do_versions_250(FileData *fd, Library *lib, Main *main)
|
|||
Lattice *lt;
|
||||
Curve *cu;
|
||||
Key *key;
|
||||
float *data;
|
||||
const float *data;
|
||||
int a, tot;
|
||||
|
||||
/* shape keys are no longer applied to the mesh itself, but rather
|
||||
|
|
|
@ -344,7 +344,7 @@ static int endwrite(WriteData *wd)
|
|||
static void writestruct_at_address(WriteData *wd, int filecode, const char *structname, int nr, void *adr, void *data)
|
||||
{
|
||||
BHead bh;
|
||||
short *sp;
|
||||
const short *sp;
|
||||
|
||||
if (adr==NULL || data==NULL || nr==0) return;
|
||||
|
||||
|
@ -1337,7 +1337,7 @@ static void write_pose(WriteData *wd, bPose *pose)
|
|||
|
||||
/* write IK param */
|
||||
if (pose->ikparam) {
|
||||
char *structname = (char *)BKE_pose_ikparam_get_name(pose);
|
||||
const char *structname = (char *)BKE_pose_ikparam_get_name(pose);
|
||||
if (structname)
|
||||
writestruct(wd, DATA, structname, 1, pose->ikparam);
|
||||
}
|
||||
|
@ -1784,7 +1784,7 @@ static void write_customdata(WriteData *wd, ID *id, int count, CustomData *data,
|
|||
write_mdisps(wd, count, layer->data, layer->flag & CD_FLAG_EXTERNAL);
|
||||
}
|
||||
else if (layer->type == CD_PAINT_MASK) {
|
||||
float *layer_data = layer->data;
|
||||
const float *layer_data = layer->data;
|
||||
writedata(wd, DATA, sizeof(*layer_data) * count, layer_data);
|
||||
}
|
||||
else if (layer->type == CD_GRID_PAINT_MASK) {
|
||||
|
|
|
@ -736,7 +736,7 @@ static void GPU_buffer_copy_normal(DerivedMesh *dm, float *varray, int *index, i
|
|||
int start;
|
||||
float f_no[3];
|
||||
|
||||
float *nors = dm->getTessFaceDataArray(dm, CD_NORMAL);
|
||||
const float *nors = dm->getTessFaceDataArray(dm, CD_NORMAL);
|
||||
short (*tlnors)[4][3] = dm->getTessFaceDataArray(dm, CD_TESSLOOPNORMAL);
|
||||
MVert *mvert = dm->getVertArray(dm);
|
||||
MFace *f = dm->getTessFaceArray(dm);
|
||||
|
@ -1384,7 +1384,7 @@ struct GPU_PBVH_Buffers {
|
|||
/* mesh pointers in case buffer allocation fails */
|
||||
MFace *mface;
|
||||
MVert *mvert;
|
||||
int *face_indices;
|
||||
const int *face_indices;
|
||||
int totface;
|
||||
const float *vmask;
|
||||
|
||||
|
@ -1393,7 +1393,7 @@ struct GPU_PBVH_Buffers {
|
|||
CCGElem **grids;
|
||||
const DMFlagMat *grid_flag_mats;
|
||||
BLI_bitmap * const *grid_hidden;
|
||||
int *grid_indices;
|
||||
const int *grid_indices;
|
||||
int totgrid;
|
||||
int has_hidden;
|
||||
|
||||
|
@ -1908,7 +1908,7 @@ static GLuint gpu_get_grid_buffer(int gridsize, GLenum *index_type, unsigned *to
|
|||
|
||||
/* used in the FILL_QUAD_BUFFER macro */
|
||||
BLI_bitmap * const *grid_hidden = NULL;
|
||||
int *grid_indices = NULL;
|
||||
const int *grid_indices = NULL;
|
||||
int totgrid = 1;
|
||||
|
||||
/* VBO is disabled; delete the previous buffer (if it exists) and
|
||||
|
@ -2520,7 +2520,7 @@ void GPU_draw_pbvh_buffers(GPU_PBVH_Buffers *buffers, DMSetMaterial setMaterial,
|
|||
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
|
||||
|
||||
if (buffers->tot_quad) {
|
||||
char *offset = 0;
|
||||
const char *offset = 0;
|
||||
int i, last = buffers->has_hidden ? 1 : buffers->totgrid;
|
||||
for (i = 0; i < last; i++) {
|
||||
glVertexPointer(3, GL_FLOAT, sizeof(VertexBufferFormat),
|
||||
|
|
|
@ -85,7 +85,7 @@ extern Material defmaterial; /* from material.c */
|
|||
static void gpu_mcol(unsigned int ucol)
|
||||
{
|
||||
/* mcol order is swapped */
|
||||
char *cp= (char *)&ucol;
|
||||
const char *cp= (char *)&ucol;
|
||||
glColor3ub(cp[3], cp[2], cp[1]);
|
||||
}
|
||||
|
||||
|
|
|
@ -330,7 +330,7 @@ struct GPUTexture {
|
|||
static unsigned char *GPU_texture_convert_pixels(int length, float *fpixels)
|
||||
{
|
||||
unsigned char *pixels, *p;
|
||||
float *fp;
|
||||
const float *fp;
|
||||
int a, len;
|
||||
|
||||
len = 4*length;
|
||||
|
|
|
@ -1237,7 +1237,7 @@ const char *IMB_colormanagement_get_rect_colorspace(ImBuf *ibuf)
|
|||
typedef struct DisplayBufferThread {
|
||||
ColormanageProcessor *cm_processor;
|
||||
|
||||
float *buffer;
|
||||
const float *buffer;
|
||||
unsigned char *byte_buffer;
|
||||
|
||||
float *display_buffer;
|
||||
|
@ -1258,7 +1258,7 @@ typedef struct DisplayBufferThread {
|
|||
typedef struct DisplayBufferInitData {
|
||||
ImBuf *ibuf;
|
||||
ColormanageProcessor *cm_processor;
|
||||
float *buffer;
|
||||
const float *buffer;
|
||||
unsigned char *byte_buffer;
|
||||
|
||||
float *display_buffer;
|
||||
|
|
|
@ -567,7 +567,7 @@ void IMB_rect_from_float(ImBuf *ibuf)
|
|||
/* converts from linear float to sRGB byte for part of the texture, buffer will hold the changed part */
|
||||
void IMB_partial_rect_from_float(ImBuf *ibuf, float *buffer, int x, int y, int w, int h, bool is_data)
|
||||
{
|
||||
float *rect_float;
|
||||
const float *rect_float;
|
||||
uchar *rect_byte;
|
||||
int profile_from = IB_PROFILE_LINEAR_RGB;
|
||||
|
||||
|
|
|
@ -263,7 +263,7 @@ void IMB_filter(struct ImBuf *ibuf)
|
|||
|
||||
void IMB_mask_filter_extend(char *mask, int width, int height)
|
||||
{
|
||||
char *row1, *row2, *row3;
|
||||
const char *row1, *row2, *row3;
|
||||
int rowlen, x, y;
|
||||
char *temprect;
|
||||
|
||||
|
|
|
@ -221,7 +221,7 @@ void bilinear_interpolation(ImBuf *in, ImBuf *out, float u, float v, int xout, i
|
|||
/* NEAREST INTERPOLATION */
|
||||
void nearest_interpolation_color(struct ImBuf *in, unsigned char outI[4], float outF[4], float u, float v)
|
||||
{
|
||||
float *dataF;
|
||||
const float *dataF;
|
||||
unsigned char *dataI;
|
||||
int y1, x1;
|
||||
|
||||
|
|
|
@ -72,7 +72,7 @@ typedef struct {
|
|||
unsigned int offset;
|
||||
unsigned int rleend; /* for rle images */
|
||||
unsigned int *rowstart; /* for rle images */
|
||||
int *rowsize; /* for rle images */
|
||||
const int *rowsize; /* for rle images */
|
||||
} IMAGE;
|
||||
|
||||
#define RINTLUM (79)
|
||||
|
|
|
@ -618,7 +618,7 @@ static void enlarge_picture_float(
|
|||
y_src = 0;
|
||||
for (y_dst = 0; y_dst < dst_height; y_dst++) {
|
||||
float *line1 = src + ((int) y_src) * 4 * src_width;
|
||||
float *line2 = line1 + 4 * src_width;
|
||||
const float *line2 = line1 + 4 * src_width;
|
||||
const float weight1y = (float)(1.0 - (y_src - (int) y_src));
|
||||
const float weight2y = 1.0f - weight1y;
|
||||
|
||||
|
@ -684,7 +684,7 @@ static void shrink_picture_float(
|
|||
float dx_dst, x_dst;
|
||||
float dy_dst, y_dst;
|
||||
float y_counter;
|
||||
float *dst_begin = dst;
|
||||
const float *dst_begin = dst;
|
||||
|
||||
struct scale_outpix_float *dst_line1;
|
||||
struct scale_outpix_float *dst_line2;
|
||||
|
@ -702,7 +702,7 @@ static void shrink_picture_float(
|
|||
y_dst = 0;
|
||||
y_counter = 1.0;
|
||||
for (y_src = 0; y_src < src_height; y_src++) {
|
||||
float *line = src + y_src * 4 * src_width;
|
||||
const float *line = src + y_src * 4 * src_width;
|
||||
uintptr_t weight1y = 1.0f - (y_dst - (int) y_dst);
|
||||
uintptr_t weight2y = 1.0f - weight1y;
|
||||
x_dst = 0;
|
||||
|
|
|
@ -307,7 +307,7 @@ static short *findstruct_name(SDNA *sdna, const char *str)
|
|||
*/
|
||||
int DNA_struct_find_nr(SDNA *sdna, const char *str)
|
||||
{
|
||||
short *sp = NULL;
|
||||
const short *sp = NULL;
|
||||
|
||||
if (sdna->lastfind < sdna->nr_structs) {
|
||||
sp = sdna->structs[sdna->lastfind];
|
||||
|
@ -566,7 +566,7 @@ SDNA *DNA_sdna_from_data(const void *data, const int datalen, bool do_endian_swa
|
|||
static void recurs_test_compflags(const SDNA *sdna, char *compflags, int structnr)
|
||||
{
|
||||
int a, b, typenr, elems;
|
||||
short *sp;
|
||||
const short *sp;
|
||||
const char *cp;
|
||||
|
||||
/* check all structs, test if it's inside another struct */
|
||||
|
@ -1307,7 +1307,7 @@ int DNA_elem_offset(SDNA *sdna, const char *stype, const char *vartype, const ch
|
|||
|
||||
const int SDNAnr = DNA_struct_find_nr(sdna, stype);
|
||||
const short * const spo = sdna->structs[SDNAnr];
|
||||
char * const cp = find_elem(sdna, vartype, name, spo, NULL, NULL);
|
||||
const char * const cp = find_elem(sdna, vartype, name, spo, NULL, NULL);
|
||||
BLI_assert(SDNAnr != -1);
|
||||
return (int)((intptr_t)cp);
|
||||
}
|
||||
|
@ -1319,7 +1319,7 @@ bool DNA_struct_elem_find(SDNA *sdna, const char *stype, const char *vartype, co
|
|||
|
||||
if (SDNAnr != -1) {
|
||||
const short * const spo = sdna->structs[SDNAnr];
|
||||
char * const cp = find_elem(sdna, vartype, name, spo, NULL, NULL);
|
||||
const char * const cp = find_elem(sdna, vartype, name, spo, NULL, NULL);
|
||||
|
||||
if (cp) return true;
|
||||
return (int)((intptr_t)cp);
|
||||
|
|
|
@ -723,7 +723,7 @@ static int arraysize(const char *str)
|
|||
static int calculate_structlens(int firststruct)
|
||||
{
|
||||
int a, b, len_native, len_32, len_64, unknown = nr_structs, lastunknown, structtype, type, mul, namelen;
|
||||
short *sp, *structpoin;
|
||||
const short *sp, *structpoin;
|
||||
const char *cp;
|
||||
int has_pointer, dna_error = 0;
|
||||
|
||||
|
@ -907,7 +907,7 @@ static void dna_write(FILE *file, const void *pntr, const int size)
|
|||
{
|
||||
static int linelength = 0;
|
||||
int i;
|
||||
char *data;
|
||||
const char *data;
|
||||
|
||||
data = (char *) pntr;
|
||||
|
||||
|
@ -925,7 +925,7 @@ void printStructLengths(void)
|
|||
{
|
||||
int a, unknown = nr_structs, structtype;
|
||||
/*int lastunknown;*/ /*UNUSED*/
|
||||
short *structpoin;
|
||||
const short *structpoin;
|
||||
printf("\n\n*** All detected structs:\n");
|
||||
|
||||
while (unknown) {
|
||||
|
@ -948,7 +948,7 @@ void printStructLengths(void)
|
|||
static int make_structDNA(const char *baseDirectory, FILE *file)
|
||||
{
|
||||
int len, i;
|
||||
short *sp;
|
||||
const short *sp;
|
||||
/* str contains filenames. Since we now include paths, I stretched */
|
||||
/* it a bit. Hope this is enough :) -nzc- */
|
||||
char str[SDNA_MAX_FILENAME_LENGTH], *cp;
|
||||
|
|
|
@ -1536,7 +1536,7 @@ static void rna_def_property_funcs(FILE *f, StructRNA *srna, PropertyDefRNA *dp)
|
|||
static void rna_def_property_funcs_header(FILE *f, StructRNA *srna, PropertyDefRNA *dp)
|
||||
{
|
||||
PropertyRNA *prop;
|
||||
char *func;
|
||||
const char *func;
|
||||
|
||||
prop = dp->prop;
|
||||
|
||||
|
|
|
@ -6104,7 +6104,7 @@ int RNA_function_call_direct_va(bContext *C, ReportList *reports, PointerRNA *pt
|
|||
}
|
||||
case PROP_STRING:
|
||||
{
|
||||
char *arg = va_arg(args, char *);
|
||||
const char *arg = va_arg(args, char *);
|
||||
err = rna_function_parameter_parse(&funcptr, parm, type, ftype, len, iter.data, &arg,
|
||||
NULL, tid, fid, pid);
|
||||
break;
|
||||
|
@ -6176,7 +6176,7 @@ int RNA_function_call_direct_va(bContext *C, ReportList *reports, PointerRNA *pt
|
|||
}
|
||||
case PROP_STRING:
|
||||
{
|
||||
char **arg = va_arg(args, char **);
|
||||
const char **arg = va_arg(args, char **);
|
||||
err = rna_function_parameter_parse(&funcptr, parm, type, ftype, len, arg, retdata,
|
||||
NULL, tid, fid, pid);
|
||||
break;
|
||||
|
|
|
@ -324,7 +324,7 @@ static int rna_member_cmp(const char *name, const char *oname)
|
|||
static int rna_find_sdna_member(SDNA *sdna, const char *structname, const char *membername, DNAStructMember *smember)
|
||||
{
|
||||
const char *dnaname;
|
||||
short *sp;
|
||||
const short *sp;
|
||||
int a, b, structnr, totmember, cmp;
|
||||
|
||||
structnr = DNA_struct_find_nr(sdna, structname);
|
||||
|
|
|
@ -801,7 +801,7 @@ static DerivedMesh *explodeMesh(ExplodeModifierData *emd,
|
|||
float rot[4];
|
||||
float cfra;
|
||||
/* float timestep; */
|
||||
int *facepa = emd->facepa;
|
||||
const int *facepa = emd->facepa;
|
||||
int totdup = 0, totvert = 0, totface = 0, totpart = 0, delface = 0;
|
||||
int i, v, u;
|
||||
unsigned int ed_v1, ed_v2, mindex = 0;
|
||||
|
|
|
@ -191,7 +191,7 @@ static void meshdeformModifier_do(
|
|||
DerivedMesh *tmpdm, *cagedm;
|
||||
MDeformVert *dvert = NULL;
|
||||
MDefInfluence *influences;
|
||||
int *offsets;
|
||||
const int *offsets;
|
||||
float imat[4][4], cagemat[4][4], iobmat[4][4], icagemat[3][3], cmat[4][4];
|
||||
float weight, totweight, fac, co[3], (*dco)[3], (*bindcagecos)[3];
|
||||
int a, b, totvert, totcagevert, defgrp_index;
|
||||
|
|
|
@ -190,7 +190,7 @@ static DerivedMesh *applyModifier(ModifierData *md, Object *ob,
|
|||
|
||||
unsigned int vc_tot_linked = 0;
|
||||
short other_axis_1, other_axis_2;
|
||||
float *tmpf1, *tmpf2;
|
||||
const float *tmpf1, *tmpf2;
|
||||
|
||||
unsigned int edge_offset;
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ void sh_node_type_base(struct bNodeType *ntype, int type, const char *name, shor
|
|||
|
||||
void nodestack_get_vec(float *in, short type_in, bNodeStack *ns)
|
||||
{
|
||||
float *from = ns->vec;
|
||||
const float *from = ns->vec;
|
||||
|
||||
if (type_in == SOCK_FLOAT) {
|
||||
if (ns->sockettype == SOCK_FLOAT)
|
||||
|
|
|
@ -75,7 +75,7 @@ static void node_shader_exec_texture(void *data, int UNUSED(thread), bNode *node
|
|||
retval = multitex_nodes((Tex *)node->id, vec, fp, fp + 3, shi->osatex, &texres, thread, which_output, NULL, NULL, NULL);
|
||||
}
|
||||
else if (in[0]->datatype == NS_OSA_VALUES) {
|
||||
float *fp = in[0]->data;
|
||||
const float *fp = in[0]->data;
|
||||
float dxt[3], dyt[3];
|
||||
|
||||
dxt[0] = fp[0]; dxt[1] = dxt[2] = 0.0f;
|
||||
|
|
|
@ -52,7 +52,7 @@ static void colorfn(float *out, TexParams *p, bNode *node, bNodeStack **UNUSED(i
|
|||
float xoff, yoff;
|
||||
int px, py;
|
||||
|
||||
float *result;
|
||||
const float *result;
|
||||
|
||||
xsize = ibuf->x / 2;
|
||||
ysize = ibuf->y / 2;
|
||||
|
|
|
@ -84,7 +84,7 @@ static void unique_name(bNode *node)
|
|||
int new_len = 0;
|
||||
int suffix;
|
||||
bNode *i;
|
||||
char *name = tno->name;
|
||||
const char *name = tno->name;
|
||||
|
||||
new_name[0] = '\0';
|
||||
i = node;
|
||||
|
|
Loading…
Reference in New Issue