r/C_Programming • • Sep 05 '26

How to get Code Review?

Hello yall,

just wondering if there was a community where I can share my code to get advice and such, so like a Code Review.

This might also be another excuse to look at other peoples code and such, but I mainly want to get advice for my code.

Im not really familiar with the coding community, I just code and make projects by myself as a hobby.

cheers, and have a good day.

5 Upvotes

26 comments sorted by

View all comments

Show parent comment

1

u/TheAmazingFreddyAdam Sep 05 '26

Any advice is appreciated, sorry in advance if my code is a mess.

0

u/AliceCode Sep 05 '26

Well, I can already tell I'm gonna need to get on my computer. First file I opened and I already saw something that can be improved with relative ease.

https://github.com/FredNeedsHelp/Ternary-Emulator/blob/main/SS_PLoader.c#L6

You could instead use an array of key/value pairs here, and if they are sorted, you can even do binary search on them.

I'll get on my PC and check it out here in a bit.

1

u/TheAmazingFreddyAdam Sep 05 '26

I think I've been planning that, i think I even left a comment on it too. thank you for the reminder / telling me in all cases.

Also, you getting on your computer isn't a bad sign right? just feels like getting a bigger screen to look at code means something is up. Which does worry me, because SSPL is the worst of my code (In my opinion. im not very familiar with parsing so thats why)

1

u/AliceCode Sep 05 '26

Well, considering how fast I found room for improvement, I'm just assuming that I'll find quite a few other things. I don't want to go back and forth between the code and reddit on my phone to type out my review.

1

u/TheAmazingFreddyAdam Sep 05 '26

Honestly, im kinda happy that you found room for improvement. I cant wait when your fully done, take your time tho.

1

u/AliceCode Sep 05 '26

Send me a reminder if you don't hear from me for awhile. I'm easily distracted. I gotta make some dinner first.

1

u/TheAmazingFreddyAdam Sep 05 '26

I guess this is your reminder, ima head to sleep, gn.

1

u/AliceCode Sep 05 '26

Remind me tomorrow, lol. I'm also going to sleep soon.

1

u/TheAmazingFreddyAdam Sep 06 '26 edited Sep 06 '26

Hi, this is your reminder (I think).

1

u/AliceCode Sep 06 '26

Oh, thanks for reminding me!

1

u/AliceCode Sep 06 '26

https://github.com/FredNeedsHelp/Ternary-Emulator/blob/fb2d225bb5292f9a2bfc99621e82d1eb71528dac/SS_PLoader.c#L71 Don't need braces for this lines like this. If there's only one statement, you don't need to surround it with braces. But it's a stylistic choice. https://github.com/FredNeedsHelp/Ternary-Emulator/blob/fb2d225bb5292f9a2bfc99621e82d1eb71528dac/SS_PLoader.c#L128 Might be better for cache if you use 256 bytes, but it doesn't really matter. It's just that with 243 bytes, that leaves room for other things on the stack to invalidate cachelines of the buffer. So if something were being mutated quite often, it might invalidate the top 51 bytes of the buffer. But like I said, it doesn't really matter. https://github.com/FredNeedsHelp/Ternary-Emulator/blob/fb2d225bb5292f9a2bfc99621e82d1eb71528dac/scrappy_striker.c#L78 Why is there an unknown error here? There likely shouldn't be an unknown error here. Do you have a way to trace the source of the error in some way? https://github.com/FredNeedsHelp/Ternary-Emulator/blob/fb2d225bb5292f9a2bfc99621e82d1eb71528dac/scrappy_striker.c#L216 Here, you set cpu.halt to true, but you don't record that it's a quit anywhere. https://github.com/FredNeedsHelp/Ternary-Emulator/blob/fb2d225bb5292f9a2bfc99621e82d1eb71528dac/scrappy_striker.c#L360 This might make more sense to be an if statement. Or better yet, skip the if statement entirely. don't need it at all. You don't seem to even need this function right now. Not much benefit writing your code like this. But if that's what you want, then there's nothing wrong with it. It's just better to not write unfinished code. https://github.com/FredNeedsHelp/Ternary-Emulator/blob/fb2d225bb5292f9a2bfc99621e82d1eb71528dac/scrappy_striker.h#L31 No contact info? lol https://github.com/FredNeedsHelp/Ternary-Emulator/blob/fb2d225bb5292f9a2bfc99621e82d1eb71528dac/scrappy_striker.h#L39 Maybe 0 for no-op. https://github.com/FredNeedsHelp/Ternary-Emulator/blob/fb2d225bb5292f9a2bfc99621e82d1eb71528dac/scrappy_striker.h#L69 Definitely get rid of the unknown error. Make it known. https://github.com/FredNeedsHelp/Ternary-Emulator/blob/fb2d225bb5292f9a2bfc99621e82d1eb71528dac/scrappy_striker.h#L81 If you need a comment to explain what a variable is, you probably need a better name for that variable. https://github.com/FredNeedsHelp/Ternary-Emulator/blob/fb2d225bb5292f9a2bfc99621e82d1eb71528dac/scrappy_striker_math.c#L8 What's with the indentation here? https://github.com/FredNeedsHelp/Ternary-Emulator/blob/fb2d225bb5292f9a2bfc99621e82d1eb71528dac/scrappy_striker_math.c#L523 Lock in.

→ More replies