Some background: I'm writing a C function that reads text from a file into a dynamically reallocated array. I start off with BUF_SIZE character, read until I've hit the limit, then reallocate. When I'm finished, I append \0 at the end of the text…
I am passing a struct through a function like so...
expandArrayofStructs(Container *container, int n)
This container is one struct and inside of that struct is an array of another type of struct I'll call it inner.
I would like to expand the size…
I have a program whose use of memory grows by 6Mb every minute. I've ran valgrind on it and cannot find any leaks. So I suspect that it's some kind of realloc inside the graphic libraries I use (and of which I do not have the source). It's a 32 bit…
I'm trying to dynamically increase memory of an int array, However I'm having issues getting it to work. It isn't expanding and adding more elements to the array, I'm not sure what I'm doing wrong.
Please help!
int* fibs = NULL;
void genFibs(){
…
I attempted implementation of a new feature on working code. However, I know from commenting out that the following lines of code are causing my program to crash.
tmp = (char*)realloc(list->array[list->size],…
So, I get this error in C function.
Variables:
int* first_array = (int*) malloc(0);
int first_array_length;
int* second_array = (int*) malloc(0);
int second_array_length;
// Setting up first array
set_up_array(first_array,…
it seems that after the second time in which the function realocVet runs, the error message "malloc: *** error for object 0x7f8bfac039b0: pointer being realloc'd was not allocated" appears.
void realocVet (float *precoList, char *nomeList, short int…
I have looked through the other discussion and still cannot figure this out. I have a struct,
typedef struct { char * word; int count; } wordType;
In my code, I malloc each array[index].word and realloc the array of structs. How do I go about…
I'm trying to concatenate strings using stdarg (library) header, but I'm doing something wrong.
There is a easier way to concatenate strings using realloc?
#include
#include
#include
#include
void…
I have a small question about using the realloc function. Assuming I have:
typedef struct
{
char* location;
int temp;
int numberOfRec;
}TEMP;
Then I declare a pointer to this struct in the main and allocate the memory:
int main()
{
TEMP*…
My problem is in the line when I call realloc(), but works with the first "Elemento"
#include
#include
using namespace std;
typedef struct{
string palabra;
string* significados;
size_t tam;
} Elemento;
typedef struct{
…
I've searched through many topics here, but they didn't seem to answer me exactly.
I'm trying to do some dynamic reallocation od arrays in C++. I can't use anything from STL libraries as I need to use this in homework where STL (vectors,...) is…
The function below tries to order strings on a linked list in ascending order. When it returns the new list, it becomes corrupted.
void* order( void *ptr){
struct wordlist *head;
head = (struct wordlist *) ptr;
struct wordlist *first =…
I'm having difficulty with coding my realloc function.
I have it working through standard memcpy procedure, but I can't get it optimized. I know there are two other cases I need to accommodate for: expanding the current block forward, and checking…