ivartj / bencoding Goto Github PK
View Code? Open in Web Editor NEWExercise in making a bencoding library.
Exercise in making a bencoding library.
github crashed on me last time I wrote this so here goes, oliverthered from wrongplanet
in no perticular order.
1: Type constants are base 2 is there an external requirement for this or could they be an enum
2: get rid of the gotos and user break properly etc...
3: define your constants as named constants #DEFINES these are manily strings used for formating in sprintf or comparison operations or other constants, this will not only self document your code but it will make them easy to change if need be and have them all defined in one place for clarity and easy reading.
4: instead of doing switch(type) for functionality instead have a struct of functionpointers and a lookup table such that (something like) functions[type]->function_name(parameters) can be used for the individual functionality for each type instead of having the code either inline or a switch case statement. most large c projects do this as a form of object orientation, it will
a: make sure the code is encapsulated for each operation for each type
b: make your code extensible
c: make you code self documenting
5: consider using memcpy instead of sprintf for constants as that's what your really doing and it's much more efficient
6: I haven't looked that well into the code but you may want some kind of stream system for buffer memory management, IDK.
apart from that not bad. ;-)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.