VOID BigInteger_AllocSize ( IN PBIG_INTEGER *pBI, IN INT Length) { UINT ArrayLength = 0; if (Length <= 0) return; if (*pBI == NULL) BigInteger_Init(pBI); /* Caculate array size */ ArrayLength = Length >> 0x2; if ((Length & 0x3) != 0) ArrayLength++; if (((*pBI)->pIntegerArray != NULL) && ((*pBI)->AllocSize < (sizeof(UINT32)*ArrayLength))) BigInteger_Free_AllocSize(pBI); if ((*pBI)->pIntegerArray == NULL) { os_alloc_mem(NULL, (UCHAR **)&((*pBI)->pIntegerArray), sizeof(UINT32)*ArrayLength); // if (((*pBI)->pIntegerArray = (UINT32 *) kmalloc(sizeof(UINT32)*ArrayLength, GFP_ATOMIC)) == NULL) { if ((*pBI)->pIntegerArray == NULL) { DEBUGPRINT("BigInteger_AllocSize: allocate %d bytes memory failure.\n", (sizeof(UINT32)*ArrayLength)); return; } /* End of if */ (*pBI)->AllocSize = sizeof(UINT32)*ArrayLength; } /* End of if */ NdisZeroMemory((*pBI)->pIntegerArray, (*pBI)->AllocSize); (*pBI)->ArrayLength = ArrayLength; (*pBI)->IntegerLength = Length; } /* End of BigInteger_AllocSize */
VOID BigInteger_Free ( IN PBIG_INTEGER *pBI) { if (*pBI != NULL) { BigInteger_Free_AllocSize(pBI); os_free_mem(NULL, *pBI); } *pBI = NULL; }
VOID BigInteger_Free ( IN PBIG_INTEGER *pBI) { if (*pBI != NULL) { BigInteger_Free_AllocSize(pBI); kfree(*pBI); } /* End of if */ *pBI = NULL; } /* End of BigInteger_Free */