diff options
author | Alan Mishchenko <alanmi@berkeley.edu> | 2019-03-05 15:57:50 -0800 |
---|---|---|
committer | Alan Mishchenko <alanmi@berkeley.edu> | 2019-03-05 15:57:50 -0800 |
commit | 01569b8f5f2394c534c3aba7276caf22493fce82 (patch) | |
tree | 40d52cf2d4d76c1e1e5bf6443c34836627f4e5f9 /src/misc/util | |
parent | b632c8496cc48bb8be0851ea2c183f94c201f791 (diff) | |
download | abc-01569b8f5f2394c534c3aba7276caf22493fce82.tar.gz abc-01569b8f5f2394c534c3aba7276caf22493fce82.tar.bz2 abc-01569b8f5f2394c534c3aba7276caf22493fce82.zip |
Fixing some warnings by adding cast from 'int' to 'size_t' in memset, memcpy, etc.
Diffstat (limited to 'src/misc/util')
-rw-r--r-- | src/misc/util/abc_global.h | 10 | ||||
-rw-r--r-- | src/misc/util/utilMem.c | 2 | ||||
-rw-r--r-- | src/misc/util/utilSort.c | 6 |
3 files changed, 9 insertions, 9 deletions
diff --git a/src/misc/util/abc_global.h b/src/misc/util/abc_global.h index c27b907e..28f0dd57 100644 --- a/src/misc/util/abc_global.h +++ b/src/misc/util/abc_global.h @@ -256,13 +256,13 @@ typedef ABC_INT64_T iword; #define ABC_PRMn(a,f) (Abc_Print(1, "%s =", (a)), Abc_Print(1, "%10.3f MB ", 1.0*(f)/(1<<20))) #define ABC_PRMP(a,f,F) (Abc_Print(1, "%s =", (a)), Abc_Print(1, "%10.3f MB (%6.2f %%)\n", (1.0*(f)/(1<<20)), ((F)? 100.0*(f)/(F) : 0.0) ) ) -#define ABC_ALLOC(type, num) ((type *) malloc(sizeof(type) * (num))) -#define ABC_CALLOC(type, num) ((type *) calloc((num), sizeof(type))) -#define ABC_FALLOC(type, num) ((type *) memset(malloc(sizeof(type) * (num)), 0xff, sizeof(type) * (num))) +#define ABC_ALLOC(type, num) ((type *) malloc(sizeof(type) * (size_t)(num))) +#define ABC_CALLOC(type, num) ((type *) calloc((size_t)(num), sizeof(type))) +#define ABC_FALLOC(type, num) ((type *) memset(malloc(sizeof(type) * (size_t)(num)), 0xff, sizeof(type) * (size_t)(num))) #define ABC_FREE(obj) ((obj) ? (free((char *) (obj)), (obj) = 0) : 0) #define ABC_REALLOC(type, obj, num) \ - ((obj) ? ((type *) realloc((char *)(obj), sizeof(type) * (num))) : \ - ((type *) malloc(sizeof(type) * (num)))) + ((obj) ? ((type *) realloc((char *)(obj), sizeof(type) * (size_t)(num))) : \ + ((type *) malloc(sizeof(type) * (size_t)(num)))) static inline int Abc_AbsInt( int a ) { return a < 0 ? -a : a; } static inline int Abc_MaxInt( int a, int b ) { return a > b ? a : b; } diff --git a/src/misc/util/utilMem.c b/src/misc/util/utilMem.c index 0bce119b..302d9008 100644 --- a/src/misc/util/utilMem.c +++ b/src/misc/util/utilMem.c @@ -153,7 +153,7 @@ static void Vec_MemSort( Vec_Mem_t * p, int (*Vec_MemSortCompare)() ) { if ( p->nSize < 2 ) return; - qsort( (void *)p->pArray, p->nSize, sizeof(void *), + qsort( (void *)p->pArray, (size_t)p->nSize, sizeof(void *), (int (*)(const void *, const void *)) Vec_MemSortCompare ); } diff --git a/src/misc/util/utilSort.c b/src/misc/util/utilSort.c index 4dca700c..32154a7d 100644 --- a/src/misc/util/utilSort.c +++ b/src/misc/util/utilSort.c @@ -434,7 +434,7 @@ void Abc_SortTest() else { clk = Abc_Clock(); - qsort( (void *)pArray, nSize, sizeof(int), (int (*)(const void *, const void *)) Abc_SortNumCompare ); + qsort( (void *)pArray, (size_t)nSize, sizeof(int), (int (*)(const void *, const void *)) Abc_SortNumCompare ); Abc_PrintTime( 1, "Old sort", Abc_Clock() - clk ); // check for ( i = 1; i < nSize; i++ ) @@ -479,14 +479,14 @@ void Abc_QuickSort1( word * pData, int nSize, int fDecrease ) int i, fVerify = 0; if ( fDecrease ) { - qsort( (void *)pData, nSize, sizeof(word), (int (*)(const void *, const void *))Abc_QuickSort1CompareDec ); + qsort( (void *)pData, (size_t)nSize, sizeof(word), (int (*)(const void *, const void *))Abc_QuickSort1CompareDec ); if ( fVerify ) for ( i = 1; i < nSize; i++ ) assert( (unsigned)pData[i-1] >= (unsigned)pData[i] ); } else { - qsort( (void *)pData, nSize, sizeof(word), (int (*)(const void *, const void *))Abc_QuickSort1CompareInc ); + qsort( (void *)pData, (size_t)nSize, sizeof(word), (int (*)(const void *, const void *))Abc_QuickSort1CompareInc ); if ( fVerify ) for ( i = 1; i < nSize; i++ ) assert( (unsigned)pData[i-1] <= (unsigned)pData[i] ); |