c

is libpng a png file decoder

I'm looking for a way to decode some png file, I heard about libpng, but I don't understand how this one works. Does it convert the png file into an array of bytes in the ARGB8888 format or something else ? ...

Is it safe to call CFRunLoopStop from another thread?

Hi all, The Mac build of my (mainly POSIX) application spawns a child thread that calls CFRunLoopRun() to do an event loop (to get network configuration change events from MacOS). When it's time to pack things up and go away, the main thread calls CFRunLoopStop() on the child thread's run-loop, at which point CFRunLoopRun() returns in...

libavcodec save encoded video to avi file ?

Hello, I manage to encode frames using libavcodec but after calling avcodec_encode_video how do I do to save my encoded frames to an avi file ? Thanks. ...

[Embedded Python] Invoking a method on an object

Given a PyObject* pointing to a python object, how do I invoke one of the object methods? The documentation never gives an example of this: PyObject* obj = .... PyObject* args = Py_BuildValue("(s)", "An arg"); PyObject* method = PyWHATGOESHERE(obj, "foo"); PyObject* ret = PyWHATGOESHERE(obj, method, args); if (!ret) { // check error....

Allowing pipe to read fragmented messages

How can I protect against fragmented messages being sent through a named pipe. Is it as simple as a while loop checking for an error or disconnect.... or is there more to it? (using winapi, named pipes in C) Thanks. ...

Free Compiler for Windows on x86_64

Hello all :) I'm writing a compiler which uses C as an intermediate code which is (Currently) passed out to MinGW for compilation into an EXE file. I'm looking for an x64 compiler that I can include in my releases, so that users of my application can get around Win64's "Windows on Windows" system to access native resources. MinGW allow...

pthread thread state

Is there a mechanism that I can use to tell if a pthread thread is currently running, or has exited? Is there a method for pthread_join() that is able to timeout after a specific period of time if the thread has not yet exited? ...

Realloc implementation

I'm writing a simple linked list based memory manager in the form: ...Header|Block|Header|Block... with a used and free list. If the realloc() function was asked to reduce the size of a block, is it okay to overwrite some of the trailing bytes with the header for the newly created block? The documentation I've read suggests this is 'un...

Thread-specific data

Hi all, If we want to use thread specific data in a multithreaded application, how to access those data from another collector thread periodically? Is it possible? Regards Ram ...

Optimizing a floating point division and conversion operation

I have the following formula float mean = (r+b+g)/3/255.0f; I want to speed it up. There are the following preconditions 0<= mean <= 1 and 0 <= r,g,b <= 255 and r, g, b are unsigned chars so if I try to use the fact that >> 8 is like dividing by 256 and I use something like float mean = (float)(((r+b+g)/3) >> 8); this will al...

vim, reformat text to initializers

I've a big file with lines that look like 2 No route to specified transit network 3 No route to destination i.e. a number at the start of a line followed by a description. And I'd like to transform that for use as a struct initializer {2,"No route to specified transit network"}, {3,"No route to destination"}, H...

Shared memory on Windows that can be accessed (read and written) by separate processes

Can I use shared memory on Windows in order to have a common memory region that can be used by multiple separate processes? Context: Porting a unix application to Windows which has: - a 'setup' process that creates a number of shared memory regions. - a set of other processes (that run at times when the setup process has already fi...

Code execution in embedded systems

Hi all, I am working in embedded system domain. I would like to know how a code gets executed from a microcontroller(uC need not be subjective, in general), starting from a C file. Also i would like to know stuffs like startup code, object file, etc. I couldnt find any online documentations regarding the above stuff. If possible, please ...

simple Pointer initialization question

Hi It has been a while that I used pointers and I just wanna quickly check how I can initialize an integer pointer? a) int *tmpPtr = 0; b) int *tmpPtr = null; c) int a = 0; int *tmpPtr = &a; EDIT Thanks for all your answers so far. The funny thing is, that if I intitalize the pointer as follows, then the mem::copy operation wor...

What are good books to study C/C++ programming in Windows?

I'm an experienced Java/C# developer. I studied C/C++ in university but have never used them to build any non-trivial software. Now I'm interested in learning about C/C++ programming in Windows and looking for good books to get started. Specifically, I want to learn about Win32 API, MFC, COM, event hook, screen capturing, multithrea...

Reading ints from file with C

Hello. This is a very simple question, but I can't seem to find something about it in here already. I want to read two integers from a file with C. My code now is this: int main() { FILE *fp; int s[80]; int t; if((fp=fopen("numbers", "r")) == NULL) { printf("Cannot open file.\n"); } else { fscanf(fp,...

Registry hive question...

Hello, Does anyone have a smal example of how to programmatically, in c/c++, load a users registry hive? I would loike to load a hive set some values and close the hive. Thanks in advance for any help. Tony ...

Reconnect to Process Started Via COM

First, I'd like to note that I need to use the COM/OLE2 APIs, the low level stuff, the stuff you can put in a C Windows Console program. I can't use MFC. I can't use .NET. My question is: Given the following code: CLSID clsid; HRESULT hr; hr = CLSIDFromProgID(L"InternetExplorer.Application", &clsid); assert(SUCCEEDED(hr)); hr ...

string parsing in C

I'm trying to pass a string to chdir(). But I always seem to have some trailing stuff makes the chdir() fail. #define IN_LEN 128 int main(int argc, char** argv) { int counter; char command[IN_LEN]; char** tokens = (char**) malloc(sizeof(char)*IN_LEN); size_t path_len; char path[IN_LEN]; ... fgets(command,...

How can I get the current time in milliseconds using C?

How might I get the current time in milliseconds in C? I am doing following to get the time in seconds: struct tm ptm; now = time(NULL); localtime_r(&now,ptm); myTime= (ptm->tm_hour * 3600) + (ptm->tm_min * 60) + (ptm->tm_sec); Looking at time.h, struct tm does not have the millisecond member in it. ...