I have this C-code to do multiplications over GF(8):
int32_t GaloisMultiply (int32_t a, int32_t b)
{
int32_t i;
int32_t mask = 0x100;
int32_t y = 0;
for(i=0;i<8;i++)
{
if(b & mask)
{
y ^= a;
}
mask >>= 1;
y <<= 1;
}
if(b & 0x1)
{
y ^= a;
}
return(y);
}
That's more or less the text-boo...
I'm trying to convert an incoming sting of 1s and 0s from stdin into their respective binary values (where a string such as "11110111" would be converted to 0xF7). This seems pretty trivial but I don't want to reinvent the wheel so I'm wondering if there's anything in the C/C++ standard libs that can already perform such an operation?
...
Systems demand that certain primitives be aligned to certain points within the memory (ints to bits that are multiples of 4, shorts to bits that are multiples of 2, etc.). Of course, these can be optimized to waste the least space in padding.
my question is why doesn't GCC do this automatically? Is the more obvious heuristic (order va...
Deep down in WinDef.h there's this relic from the segmented memory era:
#define far
#define near
This obviously causes problems if you attempt to use near or near as variable names. Any clean workarounds? Other then renaming my variables?
...
I haven't done work in C/C++ for a little bit and was just wondering what people's favorite cross platform libraries are to use.
I'm looking for something that is a good quick and dirty library as well as a library that is a little more robust. Often those are two different libraries and that's okay.
...
Why does the 'sizeof' operator return a size larger for a structure than the total sizes of the structure's members?
...
There's a lot of people today who sell unittesting as bread-and-butter of development. That might even work for strongly algorithmically-oriented routines. However, how would you unit-test, for example, a memory allocator (think malloc()/realloc()/free()). It's not hard to produce a working (but absolutely useless) memory allocator tha...
Hi
I have a TCP server that is listening on a particular interface only. I want that after the accept() call if the incoming connection was from xxx.xxx.xxx.0 subnet then the data should go through intf1 otherwise the data should be sent through intf2 which is where my server is listening.
Both the interfaces have the same route setti...
How can I setup a shared ccache without falling into a permissions problem?
I would like to run a nightly or CI build with latest changes and share all created binaries throughout the R&D using a large ccache repository.
...
i need to know where i can get free version of C,C++ compilers for windows vista.many of the versions i tried are not working in fullscreen mode.
...
I would like to replace the default malloc at link time to use a custom malloc. But when I try to redefine malloc in my program, I get this error:
MSVCRT.lib(MSVCR80.dll) : error LNK2005: _malloc already defined in test.lib(test.obj)
This works perfectly on any Unix, and it works on Windows with most functions, but not with malloc. Ho...
What is the best (cleanest, most efficient) way to write saturating addition in C?
The function or macro should add two unsigned inputs (need both 16- and 32-bit versions) and return all-bits-one (0xFFFF or 0xFFFFFFFF) if the sum overflows.
Target is x86 and ARM using gcc (4.1.2) and Visual Studio (for simulation only, so a fallback im...
So, we saw the post on Code Smells and how to fix them...but what about for us NON object oriented folk? I use embedded C a LOT and while all the responses to the said post were great, I wondered if anyone had some input about the straight-C world? Some of the things mentioned in the other post do not apply (and some were even complete...
Is there a clean, preferably standard method of trimming leading and trailing whitespace from a string in C? I'd roll my own, but I would think this is a common problem with an equally common solution.
...
I'm looking for a simple, easy to understand algorithm to alphabetically sort an array of characters in C.
...
So I've got some C code:
#include <stdio.h>
#include <string.h>
/* putting one of the "char*"s here causes a segfault */
void main() {
char* path = "/temp";
char* temp;
strcpy(temp, path);
}
This compiles, runs, and behaves as it looks. However, if one or both of the character pointers is declared as global variable, strcpy res...
I am working on an application that detects the most prominent rectangle in an image, then seeks to rotate it so that the bottom left of the rectangle rests at the origin, similar to how IUPR's OSCAR system works. However, once the most prominent rectangle is detected, I am unsure how to take into account the depth component or z-axis, ...
I've been learning C, and I'm looking for a (preferably very) simple open source project to get into. It will most likely involve more playing around and learning on my part than actual contribution, but it seems a great way to gain some experience and see how C is really used. Any ideas?
...
To save network traffic I'd like to compress my data. The only trick is that I the client is a c application and the server is php. I'm looking for an open source compression library that's available for both c and php.
I guess I could write an external c application to decompress my data, but I'm trying to avoid spawning extra processe...
How do you do low low level sockets in C, example: actually sending a SYN.
...