Using Malloc Hooks
I am trying to use a malloc hook to create a custom function my_malloc(). In my main program when I call malloc() I want it to call my_malloc() can someone please give me an example on how to do this in C ...
I am trying to use a malloc hook to create a custom function my_malloc(). In my main program when I call malloc() I want it to call my_malloc() can someone please give me an example on how to do this in C ...
I've incorporated LIBPNG and ZLIB into my C software for a microcontroller project due to their nicely liberal license which permits such use without requiring me to disclose any of my code (it's very similar to BSD/MIT/APACHE, but with no attribution requirement). I'd like to look at using lossy image compression to save memory. The J...
My comany is transistioning from assembly coded microcontrollers to C. We are considering Microchip, Atmel, Renasas, et. al. for future projects using C code. Are there good training resources to bring our engineers up to speed with C? Seminars, instructors, classes, etc. The experience level of the engineers varies from no training ...
I have two Slackware Linux systems on which the POSIX semaphore sem_open() call fails with errno set to 38. Sample code to reproduce below (the code works fine on CentOS / RedHat). Are there any kernel or system configuration options that could cause this? Other suggestions? Systems with issue are Slackware 10.1.0 kernel 2.6.11 /lib/li...
I have a char array buffer that I am using to store characters that the user will input one by one. My code below works but has a few glitches that I can't figure out: when I execute a printf to see what's in Buffer, it does fill up but I get garbage characters at the end it won't stop at 8 characters despite being declared as char Bu...
I am using the "MySQL C API" to query the database and I have the results stored in MYSQL_ROW types. I am able to use print the results to the console with printf("%s", row[0]), however, according to the MySQL C API documentation, I cannot use them as null-terminated strings. At the bottom of http://dev.mysql.com/doc/refman/5.0/en/c-ap...
I am trying to get this program to give me an out put that when I do an addition, subtraction, multiplication, or division problem it will give me the answer. However, it is not working can anyone help. int main () { int choice; float a, b; float sum; float difference; float product; float quotiont; printf("This p...
I want to build software of the good old sliding block puzzle for mobile phones could you please guide me how to generate the sliding block puzzle and solving techniques ...
Through profiling I've discovered that the sprintf here takes a long time. Is there a better performing alternative that still handles the leading zeros in the y/m/d h/m/s fields? SYSTEMTIME sysTime; GetLocalTime( &sysTime ); char buf[80]; for (int i = 0; i < 100000; i++) { sprintf(buf, "%4d-%02d-%02d %02d:%02d:%02d", sysTime.wYear...
I'd much rather code an app using pure C api such as OpenGL, rather that Cocoa Touch. So I'm wondering: is it feasible? Will I be able to maintain the same user experience that you get with Interface Builder? ...
Hi, I am using the following code fragment in a php script to safely update a shared resource. $lock_id = sem_get( ftok( 'tmp/this.lock', 'r')); sem_acquire($lock_id) //do something sem_release($lock_id) When I stress test this code with large number of requests I get an error: Warning: semop() failed acquiring SYSVSEM_SETVAL for k...
char *strtok(char *s1, const char *s2) repeated calls to this function break string s1 into "tokens"--that is the string is broken into substrings, each terminating with a '\0', where the '\0' replaces any characters contained in string s2. The first call uses the string to be tokenized as s1; subsequent calls use NUL...
Is it ever acceptable to have a memory leak in your C or C++ application? What if you allocate some memory and use it until the very last line of code in your application (for example, a global object's deconstructor)? As long as the memory consumption doesn't grow over time, is it OK to trust the OS to free your memory for you when you...
I want to create a library with a modified version of printf and then call LD_PRELOAD so when my program calls printf it uses my version. Can someone explain to me how to use LD_PRELOAD and if there is a something special I need to do in my code or my library? ...
Is there any way to decode a PICS Rules File? Contains settings and preferences used by the Windows operating system. The file is given by: Q:F]9y3n5|dp:n4hU)qbs;!&-bzh ...
In the C / Unix environment I work in, I see some developers using __progname instead of argv[0] for usage() messages. Is there some advantage to this? What's the difference between __progname and argv[0]. Is it portable? ...
Similar to this question but for MySQL.... How can I programmatically determine foreign key references in MySQL (assuming InnoDB)? I can almost get them with: SHOW TABLE STATUS WHERE Name = 'MyTableName'; ...but alas, the comment column which seems to contain some of this info gets truncated so I can't rely on it. There must be som...
How does one prevent an inclusion cycle in C? ie. You shouldn't have a.h #include "b.h", which #include's "c.h" which #include's "a.h". I'm looking for a way of preventing this from happening using some sort of C directive. I had originally thought this would've prevented this from happening: Contents of a.h: #ifndef __A_H #define __A...
I want to setup a statistics monitoring platform to watch a specific service, but I'm not quiet sure how to go about it. Processing the intercepted data isn't my concern, just how to go about it. One idea was to setup a proxy between the client application and the service so that all TCP traffic went first to my proxy, the proxy would ...
There seem to be 3 ways of telling GCC to weak link a symbol: __attribute__((weak_import)) __attribute__((weak)) #pragma weak symbol_name None of these work for me: #pragma weak asdf extern void asdf(void) __attribute__((weak_import, weak)); ... { if(asdf != NULL) asdf(); } I always get a link error like this: Undefined symbo...