Skip to content

apply of '#81 Fix casting pointer to different size integer'#20

Closed
efa wants to merge 3 commits intogerbv:mainfrom
efa:main
Closed

apply of '#81 Fix casting pointer to different size integer'#20
efa wants to merge 3 commits intogerbv:mainfrom
efa:main

Conversation

@efa
Copy link
Copy Markdown
Contributor

@efa efa commented Sep 13, 2021

apply of '#81 Fix casting pointer to different size integer'
https://sourceforge.net/p/gerbv/patches/81/
as opening a .gvp file on Windows always crash

This and the next one are necessary to work on Windows too.
Follow the PR for #77 Fix double-freeing memory

@ooxi
Copy link
Copy Markdown
Contributor

ooxi commented Sep 13, 2021

I don't quite get this patch :-( ADJ is defined to be 32 so it is not a pointer, more like a size. Shouldn't we change unsigned int to size_t from stddef.h instead of uintptr_t from from stdint.h?

efa added 2 commits September 14, 2021 13:31
https://sourceforge.net/p/gerbv/patches/81/
but changed 'uintptr_t' to 'size_t'
as opening a .gvp file on Windows always crash

I re-tested also on Linux
@efa
Copy link
Copy Markdown
Contributor Author

efa commented Sep 14, 2021

'size_t' has the same size of 'uintptr_t' used by @kitanokitsune on all 32 and 64-bit systems I know, and it is still unsigned, but it is certainly better for a size like adj=sizeof()

@ooxi
Copy link
Copy Markdown
Contributor

ooxi commented Sep 16, 2021

Thank you very much @efa for providing this patch! I have reintegrated your commit 71c623c as e4b344e (added stddef.h include) in pull request #23

@ooxi ooxi closed this Sep 16, 2021
@eyal0
Copy link
Copy Markdown
Collaborator

eyal0 commented Sep 17, 2021

Add a static_assert that the sizeof one is equal to the sizeof the other and then you will never have a question about whether or not the size is right. The compiler will tell you the answer with no effort.

It's nice when the computer can enforce rules for us.

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

Successfully merging this pull request may close these issues.

3 participants