C / C++ Code Portfolio


exit(EXIT_FAILURE); } // Return pointer to allocated memory return



Download 112,15 Kb.
bet6/30
Sana01.03.2022
Hajmi112,15 Kb.
#475852
1   2   3   4   5   6   7   8   9   ...   30
Bog'liq
dddd

exit(EXIT_FAILURE);
}
// Return pointer to allocated memory
return(vp);
}

Type **Create2D(size_t rows, size_t cols)


{
Type **beginPtr, **currentRow, *nextRow, **lastRow;
// allocate enough memory to contain the entire array
beginPtr = (Type **)SafeMalloc(rows * sizeof(Type *) + rows * cols * sizeof(Type));
// compute the address of the location of the last row
lastRow = beginPtr + rows;
nextRow = (Type *)lastRow;
// for each row, store the address of each row in the Type* array
for (currentRow = beginPtr; currentRow < lastRow; ++currentRow, nextRow += cols)
{
*currentRow = nextRow;
}
// return a pointer to the start of the array
return(beginPtr);
}

void Free2D(void *p)
{
// free memory pointed to by p
free(p);
}
// This function dynamically allocates a block of memory containing newSize bytes and
// resizes an existing block containing oldSize bytes to contain newSize bytes. All existing data
// from pOld that will fit into newSize bytes will be preserved.

#include



void *ResizeAlloc(void *pOld, size_t newSize, size_t oldSize)
{
// if new memory is 0 bytes in size, return null pointer and quit
if (newSize == 0)
{
return(NULL);
}
// otherwise, if new memory is greater than 0 bytes
else
{
// allocate new block of memory newSize bytes in size. if allocation fails, return
// null pointer and quit
unsigned char *newAllocatedPointer;
if ((newAllocatedPointer = (unsigned char *)malloc(newSize * sizeof(unsigned char))) == NULL)
{
return(NULL);
}
// otherwise if pOld is a null pointer, just return a pointer to the newly allocated memory

Download 112,15 Kb.

Do'stlaringiz bilan baham:
1   2   3   4   5   6   7   8   9   ...   30




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish