Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unnecessary malloc casts #7

Open
johnramsden opened this issue Oct 25, 2020 · 3 comments
Open

Unnecessary malloc casts #7

johnramsden opened this issue Oct 25, 2020 · 3 comments

Comments

@johnramsden
Copy link
Collaborator

malloc (and realloc) return void pointers and do not require casts.

buffers=(struct embedding_buffer**)malloc(NR_TABLES*sizeof(struct embedding_buffer*));

buffers[total_buffers]=(struct embedding_buffer*)malloc(sizeof(struct embedding_buffer));

buffers[total_buffers+j]=(struct embedding_buffer*)malloc(sizeof(struct embedding_buffer));

buffers=(struct embedding_buffer**)realloc(buffers, buff_arr_len*(sizeof(struct embedding_buffer*)));

buffers[total_buffers]->data=(int32_t*)malloc(ALIGN((last_row-first_row+1)*nr_cols*sizeof(int32_t),8));

tables[i].buffers=(struct embedding_buffer**)malloc(tables[i].nr_buffers*sizeof(struct embedding_buffer*));

@nzarif
Copy link
Collaborator

nzarif commented Oct 28, 2020

Are they unnecessary? I think I was getting type errors (not sure) and that was why I added these.

@johnramsden
Copy link
Collaborator Author

Yes, they should be unnecessary.

@nzarif
Copy link
Collaborator

nzarif commented Oct 28, 2020

Ok, I will remove them and see what happens.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants