rewrote memory allocation and clear function tests not working
This commit is contained in:
parent
0a909936ed
commit
7698e94944
46
imageInput.c
46
imageInput.c
@ -34,13 +34,20 @@ GrayScaleImageSeries *readImages(const char *path)
|
|||||||
{
|
{
|
||||||
|
|
||||||
//Speicheralloziierung komplett umschreichen!!!!!
|
//Speicheralloziierung komplett umschreichen!!!!!
|
||||||
// Series reservieren mit größe einer grayscaleImageSeries
|
// done Series reservieren mit größe einer grayscaleImageSeries
|
||||||
// ein series->count reservieren mit größe unsigned int
|
// done initiales image für statusinfos
|
||||||
// series->labels reservieren mit zahl count und größe int
|
// done series->labels reservieren mit zahl count und größe int
|
||||||
// series->images[i].buffer mit zahl series->count *numberOfBytesToRead und size of unsigned Char
|
// done für anzahl count series->images mit size of grayscaleImage
|
||||||
|
// done für jedes image series->images[i].buffer mit zahl series->count *numberOfBytesToRead und size of unsigned Char
|
||||||
|
|
||||||
|
/*
|
||||||
series = calloc(amountOfStatusInfoToRead, (3 * sizeof(unsigned int) + 3 * sizeof(headerString)));
|
series = calloc(amountOfStatusInfoToRead, (3 * sizeof(unsigned int) + 3 * sizeof(headerString)));
|
||||||
series->images = calloc(amountOfStatusInfoToRead, (2 * sizeof(unsigned int) + sizeof(headerString)));
|
series->images = calloc(amountOfStatusInfoToRead, (2 * sizeof(unsigned int) + sizeof(headerString)));
|
||||||
|
// */
|
||||||
|
|
||||||
|
series = calloc(amountOfStatusInfoToRead, sizeof(GrayScaleImageSeries));
|
||||||
|
|
||||||
|
series->images = calloc(1, sizeof(GrayScaleImage));
|
||||||
|
|
||||||
numberOfBytesToRead = readStatusInfo(readSource, series, headerString, sizeOfStausInfoElementsInBytes, amountOfStatusInfoToRead);
|
numberOfBytesToRead = readStatusInfo(readSource, series, headerString, sizeOfStausInfoElementsInBytes, amountOfStatusInfoToRead);
|
||||||
|
|
||||||
@ -49,7 +56,8 @@ GrayScaleImageSeries *readImages(const char *path)
|
|||||||
// printf("llu %llu\n", series->count * numberOfBytesToRead * sizeof(GrayScalePixelType));
|
// printf("llu %llu\n", series->count * numberOfBytesToRead * sizeof(GrayScalePixelType));
|
||||||
// printf("count %d\n", series->count);
|
// printf("count %d\n", series->count);
|
||||||
// series->images[0].buffer = calloc(((series->count) * numberOfBytesToRead), sizeof(GrayScalePixelType));
|
// series->images[0].buffer = calloc(((series->count) * numberOfBytesToRead), sizeof(GrayScalePixelType));
|
||||||
series->labels = calloc((series->count), sizeof(&(series->labels)));
|
series->images = realloc(series->images, series->count * sizeof(GrayScaleImage));
|
||||||
|
series->labels = calloc((series->count), sizeof(&(series->labels)));
|
||||||
|
|
||||||
if (expectedHeader)
|
if (expectedHeader)
|
||||||
{
|
{
|
||||||
@ -107,6 +115,32 @@ void clearSeries(GrayScaleImageSeries * series)
|
|||||||
int j = 0;
|
int j = 0;
|
||||||
|
|
||||||
|
|
||||||
|
for (i = 0; i < series->count; i++)
|
||||||
|
{
|
||||||
|
for (j = 0; j < series->images[i].width * series->images[i].height; j++)
|
||||||
|
{
|
||||||
|
series->images[i].buffer[j] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
series->labels[i] = 0;
|
||||||
|
series->images[i].width = 0;
|
||||||
|
series->images[i].height = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < series->count; i++)
|
||||||
|
{
|
||||||
|
free(series->images[i].buffer);
|
||||||
|
series->images[i].buffer = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
free(series->labels);
|
||||||
|
series->labels = NULL;
|
||||||
|
free(series->images);
|
||||||
|
series->images = NULL;
|
||||||
|
free(series);
|
||||||
|
series = NULL;
|
||||||
|
|
||||||
|
/*
|
||||||
// Write NULL into all memory spaces
|
// Write NULL into all memory spaces
|
||||||
|
|
||||||
for (i = 0; i < series->count; i++)
|
for (i = 0; i < series->count; i++)
|
||||||
@ -138,7 +172,7 @@ void clearSeries(GrayScaleImageSeries * series)
|
|||||||
series = NULL;
|
series = NULL;
|
||||||
|
|
||||||
printf("cleared\n");
|
printf("cleared\n");
|
||||||
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
// Write NULL into all memory spaces
|
// Write NULL into all memory spaces
|
||||||
|
|||||||
BIN
testFile.info2
Normal file
BIN
testFile.info2
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user