11
Simple C hashtable code
Filed Under (C, Coding, Open source) by 2of1 on 11-07-2011
Here’s some code for a simple C hashtable.
Read the rest of this entry »
11
Here’s some code for a simple C hashtable.
Read the rest of this entry »
04
Here are the slides and code examples of the talk that I gave at the 7th DC9723 meet a few weeks ago.
To all those that came; thanks – I hope you found it interesting!
03
cpp -dM /dev/null
21
Here are two easy ways to compile 32-bit binaries on a 64-bit system.
Read the rest of this entry »
23
Peter van der Linden brought up a point regarding strcmp() his book Expert C Programming: Deep C Secrets that I found interesting.
Read the rest of this entry »
21
UPDATE: See comments
Linux purists are going to go crazy at this, but I was looking for a way to write to the kernel ring buffer (read by dmesg) from a userspace script.
I’m not going to debate the ‘whys’ – but in short I like having my sys logs for automated system actions (some which are userspace-launched) in one neat place.
Read the rest of this entry »
17
There’s a quick and effective way of producing a random value in C if you only require it at most once per second using current time as a random seed:
#include <time.h> // time_t, time() #include <stdlib.h> // srand(), rand() time_t s; time(&s); srand((unsigned int)s); // calc random value (limits are inclusive) int rand_val = 1 + (int)((float)UPPER_LIMIT * (rand() / (RAND_MAX + (float)LOWER_LIMIT)));
Of course reading from /dev/urandom is good too
(on linux).
22
I wrote some Direct2D compatibility headers to allow for cross-compilation using MingW or mingw-w64.
Read the rest of this entry »
22
A while back I wrote a tool to build Direct2D api headers off the public information on MSDN.
Yesterday I noticed that my vlc patch – while compiling fine – crashes on a certain D2D API call.
The reason for this it seems that my generation tool pulls off the API from MSDN in the order that it appears there – i.e. alphabetical order.
Read the rest of this entry »
21
When connect()ing to a server, there is no direct way to define a timeout for that connection attempt – meaning that you could be waiting for a LONG time.