I need to cache a large (but variable) number of smallish (1 kilobyte to 10 megabytes) files in memory, for a C application (in a *nix environment). Since I don't want to eat all my memory, I'd like to set hard memory limit (say, 64 megabytes) and push files into a hash table with the file name as the key and dispose of the entries with ...
Hello,
I need in global list in my gtk+ application, i use for it GList:
For example:
I have structure:
typedef struct _data
{
Glist list;
}Data;
I want to use one copy of the list in the whole program:
I have a function bulid my list:
gboolean build_list()
{
Data->list = g_list_append(Data->list, "First ");
Data->list = ...
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int main(){
int n;
int a,b,ans[10000];
char *c,*d,*e;
int i = 0;
c = (char*)(malloc(20 * sizeof(char)));
d = (char*)(malloc(20 * sizeof(char)));
scanf("%d",&n);
while(i < n){
scanf("%d",&a);
scanf("%d",&b);
itoa(a,...
When I try to initialize a 3D array of size 300*300*4 in a C program, my program stops running and reports stack overflow error. The system I am using has 3GB RAM, which should be sufficeint. Is there any way to increase memory allocated to a program? I am using Dev C++ on Windows Vista.
...
I'm looking for a C library that provides generic collection data structures such as lists, associative arrays, sets, etc. The library should be stable and well tested. I'm basically looking for something better than the crappy C standard library.
What C libraries fit this description?
EDIT: I'd prefer that the library was cross-platfo...
How to encode RBG images into on VP8 frames (Keyframe + some dependent frames)?
So I created some images how to turn tham into VP8 now?
...
Hey,
How can i pass (and access) using C, not c++, variable parameters into a function?
void foo(char* mandatory_param, char* optional_param, char* optional_param2...)
thanks
/fmsf
...
Possible Duplicate:
What does unsigned temp:3 means
I came across some code like this that I am not sure with:
unsigned long byte_count : 32
unsigned long byte_count2 : 28
What does the : mean here?
...
Hi
I'm working on a project where I have code like the following:
#define NAME() Array
inline NAME()* NAME()_init (void* arg0){return (NAME()*)Object_init(arg0);}
But I get the following result:
inline Array* Array _init (void* arg0){return (Array*)Object_init(arg0);}
With a space between the "Array" and the "_init"
Because this ...
This is a simplified example of the problem I have:
#include <stdio.h>
#include <stdlib.h>
void f2(int** a) {
printf("a: %i\n", **a);
}
void f1(int* a) {
f2(&a);
}
int main() {
int a = 3;
f1(&a); // prints "a: 3"
f2(???);
return 0;
}
The problem is that I would like to be able to use f2() both in main() and in f1().
...
After reading some examples on stackoverflow, and following some of the answers for my previous questions (1), I've eventually come with a "strategy" for this.
I've come to this:
1) Have a declare section in the .h file. Here I will define the data-structure, and the accesing interface. Eg.:
/**
* LIST DECLARATION. (DOUBLE LINKED LI...
is there some way to embed pragma statement in macro with other statements?
I am trying to achieve something like:
#define DEFINE_DELETE_OBJECT(type) \
void delete_ ## type_(int handle); \
void delete_ ## type(int handle); \
#pragma weak de...
Using C++ and GCC, can I declare an extern variable that uses a specific address in memory?
Something like
int key __attribute__((__at(0x9000)));
AFAIK this specific option only works on embedded systems. If there is such an option for use on the x86 platform, how can I use it?
...
I am going to call a Vala function from C, and I have a question about memory management.
The function looks like this in Vala:
int[] GetNumbers();
and is translated by valac to C like this
gint* GetNumbers(int* result_length1);
When the above function gets called from C, is the caller responsible for freeing the gint* array?
...
I'm rendering 2D polygons with the GLUTesselator the first time, then they are stored in a display list for subsequent use. I think VBO's might be faster, but since I can't access the stuff that the tesselator outputs, and since it uses mixes of gl_triangle, quad, strip etc, i'm not sure how I could do this, even though I would like to u...
Possible Duplicate:
Dealing with accuracy problems in floating-point numbers
I was quite surprised why I tried to multiply a float in C (with GCC 3.2) and that it did not do as I expected.. As a sample:
int main() {
float nb = 3.11f;
nb *= 10;
printf("%f\n", nb);
}
Displays: 31.099998
I am curious regarding the way f...
Heads up: This is a weird question.
I've got some really useful macros that I like to use to simplify some logging. For example I can do Log(@"My message with arguments: %@, %@, %@", @"arg1", @"arg2", @"arg3"), and that will get expanded into a more complex method invocation that includes things like self, _cmd, __FILE__, __LINE__, etc...
Looking for good source code either in C or C++ or Python to understand how a hash function is implemented and also how a hash table is implemented using it.
Very good material on how hash fn and hash table implementation works.
Thanks in advance.
...
I have used timer A in MSP430 with high compiler optimization, but found that my timer code is failing when high compiler optimization used.
When none optimization is used code works fine.
This code is used to achieve 1 ms timer tick. timeOutCNT is increamented in interrupt.
Following is the code
//Disable interrupt and clear CCR0
...
In the make_quad() function below, how do I set the default values for the vertex_color array in the quad_t structure?
/* RGBA color */
typedef struct {
uint8_t r,g,b,a;
} rgba_t;
/* Quad polygon - other members removed */
typedef struct {
rgba_t vertex_color[ 4 ];
} quad_t;
Elsewhere, a function to make and init a quad:
qua...