c

Dot product - SSE2 vs BLAS

What's my best bet for computing the dot product of a vector x with a large number of vectors y_i, where x and y_i are of length 10k or so. Shove the y's in a matrix and use an optimized s/dgemv routine? Or maybe try handcoding an SSE2 solution (I don't have SSE3, according to cpuinfo). I'm just looking for general guidance her...

What is wrong with my X11 code?

I am attempting to get the X Window at a certain location on screen. When I asked people for a function to do this, they said you would just call XQueryTree recursively. This is the code snippet which I think is somehow wrong. When I debug it, it seems to work perfectly. The only problem is that the output it gives seems a little str...

How do I play flash files in pure C?

As part of a customized media player written in C (Win32), I need to enable my app play flash movies (.swf files) inside the player window. Can someone please indicate the most C compatible low level way to achieve this, giving me highest control? Specially control on display window and network access. I am looking for reference to a Wi...

Best unit testing framework for old school QNX ?

I'm working on an old variant of unix (qnx 4.x to be exact). I'm trying to shoe-horn in modern software methodologies atop 20+ year old technology. In short I need a unit testing framework for QNX. Keep in mind we've got a bare bones C compiler and that's pretty much it. Anyone got any suggestions on how I can unit test this beast? ...

most efficient winsock design for high load network application

Hello, I know it is a general question but I need your recommodations about a TCP server/client application. The server is only supposed to handle one connection at a time. Server is sending live images (one frame is approx. 50K and 20 frames per second) to connected client. Actually at the startup of the server and client applicatio...

Array of member function pointers : Getting 0xcccccccc when control reached pointer to member function

Hi, I got error Access Violation when the following code is execute : void NoAction() { (*m_psStateMachine[0][0])(); } class CXcp { public: CXcp(){} CXcp(WORD wXcpProtocol); ~CXcp(); private: void (*m_psStateMachine[10][16])(); public: // Action Methods from State M/c Table in the RFC// void IrcScr_6(){} void IrcS...

In C, declare and initialize a variable in a small function or just return a response.

Coming from a PHP background, I'm used to writing small functions that return a string (or the response from another function) like so: function get_something(){ return "foo"; } However, I'm new to C and am trying to figure how to do some really fundamental things like this. Can people review the following similar functions and t...

Objective-C: unichar vs. char

I'm a little confused between a unichar and a char. Can I treat unichar's similar to char's? For example, can I do this: -(BOOL)isNewLine:(unichar)c { if(c == '\n') return YES; else return NO; } ...

Calling Specific Win32 API from Delphi - Why do Exceptions Fly Without an "asm pop..."?

I'm using Delphi to make an XLL add-in for Excel, which involves making a lot of calls to the Excel4v function of xlcall32.dll. However, as I'm guessing very few Delphi experts here have worked with that specific API, I'm hoping that the problem might have been observed in other APIs too. In C, specifically in the xlcall.h file that co...

Failed to free a colormap entry in Xlib with XFreeColors()

I allocate a color entry with the next code, then I use it to draw correctly: char *color_name = "red"; XColor color, exact; XAllocNamedColor(display, colormap, color_name, &color, &exact); Then, when I don't need anymore the color entry, I try to free it: XFreeColors(display, colormap, &color.pixel, 1, 0); This call generates the...

Pulling MX record from DNS server

I am writing an application that is requiring me to do a DNS lookup for an MX record. I'm not sure if anyone has had experience doing this kind of work but if you do, any help would be appreciated. EDIT: The thing that I'm going for is an application that will send an e-mail alert. The problem is I need to have the application be able...

mq_unlink setting errno to EEXIST

I'm using message queues for inter-thread communication in a server. The server was functioning as expected on Thursday evening. When I picked the project back up on Monday, it was unable to create two of the six queues in use, citing that they were already open (O_EXCL is set). This should not have been the case, but nevertheless I a...

Faster to malloc multiple small times or few large times?

When using malloc to allocate memory, is it generally quicker to do multiple mallocs of smaller chunks of data or fewer mallocs of larger chunks of data? For example, say you are working with an image file that has black pixels and white pixels. You are iterating through the pixels and want to save the x and y position of each black pi...

Issues writing to serial port on MAC OSX using unistd.h in c

I am trying to write to a bluetooth device on MAC OSX using the unistd.h Linux functions in c. I am connecting fine and writing the first few bytes with success. When I try to write other commands to it (there are bytes added to the write buffer every 15ms), I don't see any results even though the write() function returns 1 (write succes...

Problem in overriding malloc

Hi, I am trying to override malloc by doing this. #define malloc(X) my_malloc((X)) void* my_malloc(size_t size) { void *p = malloc(size); printf ("Allocated = %s, %s, %s, %x\n",__FILE__, __LINE__, __FUNCTION__, p); return p; } However, this is indefinitely calling my_malloc recursively (because of malloc call inside my_...

Convert objective-c typedef to its string equivalent

Assuming that I have a typedef declared in my .h file as such: typedef enum { JSON, XML, Atom, RSS } FormatType; I would like to build a function that converts the numeric value of the typedef to a string. For example, if the message [self toString:JSON] was sent; it would return 'JSON'. The function would look something lik...

Writing a portable command line wrapper in C.

I'm writing a perl module called perl5i. Its aim is to fix a swath of common Perl problems in one module (using lots of other modules). To invoke it on the command line for one liners you'd write: perl -Mperl5i -e 'say "Hello"' I think that's too wordy so I'd like to supply a perl5i wrapper so you can write perl5i -e 'say "Hello"'. I...

How to correctly destruct token semantic values (symbol records) and avoid memory leaks using GNU Bison?

I'm writing a simplified Pascal parser/interpreter and now I'm thinking about segmentation faults. I'm not getting them yet, everything is running fine, but since I'm developing under Cygwin, I can't test the program through valgrind. Basically what I'm doing is described below: typedef struct{ char idType; //Integer (i), Real (r),...

ReadDirectoryChangesW implementation

Originally I was linked to this call so I could log all access to a certain file and capture all the changes to it. I have worked through several examples and have failed. Even the MSDN code doesn't compile for me. Can someone provide me with a small working snippet to monitor a file and record changes? Or at least some pointers? Th...

CreateDirectory() C (Windows VISTA/XP)

How can I create a directory in C and assign an icon to the folder all with in my program? The point of this is all doing this in one program without any other dependencies. Is this possible? ...