Use xmalloc() instead of malloc().

svn path=/trunk/yasm/; revision=265
0.3
Peter Johnson 23 years ago
parent c49daeab12
commit fef39125bc
  1. 16
      libyasm/bitvect.c
  2. 16
      src/bitvect.c

@ -286,7 +286,7 @@ ErrCode BitVector_Boot(void)
FACTOR = LOGBITS - 3; /* ld(BITS / 8) = ld(BITS) - ld(8) = ld(BITS) - 3 */
MSB = (LSB << MODMASK);
BITMASKTAB = (wordptr) malloc((size_t) (BITS << FACTOR));
BITMASKTAB = (wordptr) xmalloc((size_t) (BITS << FACTOR));
if (BITMASKTAB == NULL) return(ErrCode_Null);
@ -345,7 +345,7 @@ wordptr BitVector_Create(N_int bits, boolean clear) /* malloc */
size = BitVector_Size(bits);
mask = BitVector_Mask(bits);
bytes = (size + BIT_VECTOR_HIDDEN_WORDS) << FACTOR;
addr = (wordptr) malloc((size_t) bytes);
addr = (wordptr) xmalloc((size_t) bytes);
if (addr != NULL)
{
*addr++ = bits;
@ -426,7 +426,7 @@ wordptr BitVector_Resize(wordptr oldaddr, N_int bits) /* realloc */
else
{
bytes = (newsize + BIT_VECTOR_HIDDEN_WORDS) << FACTOR;
newaddr = (wordptr) malloc((size_t) bytes);
newaddr = (wordptr) xmalloc((size_t) bytes);
if (newaddr != NULL)
{
*newaddr++ = bits;
@ -1317,7 +1317,7 @@ charptr BitVector_to_Hex(wordptr addr)
length = bits >> 2;
if (bits AND 0x0003) length++;
string = (charptr) malloc((size_t) (length+1));
string = (charptr) xmalloc((size_t) (length+1));
if (string == NULL) return(NULL);
string += length;
*string = (N_char) '\0';
@ -1388,7 +1388,7 @@ charptr BitVector_to_Bin(wordptr addr)
charptr string;
length = bits_(addr);
string = (charptr) malloc((size_t) (length+1));
string = (charptr) xmalloc((size_t) (length+1));
if (string == NULL) return(NULL);
string += length;
*string = (N_char) '\0';
@ -1471,7 +1471,7 @@ charptr BitVector_to_Dec(wordptr addr)
length = (N_word) (bits / 3.3); /* digits = bits * ln(2) / ln(10) */
length += 2; /* compensate for truncating & provide space for minus sign */
result = (charptr) malloc((size_t) (length+1)); /* remember the '\0'! */
result = (charptr) xmalloc((size_t) (length+1)); /* remember the '\0'! */
if (result == NULL) return(NULL);
string = result;
sign = BitVector_Sign(addr);
@ -1743,7 +1743,7 @@ charptr BitVector_to_Enum(wordptr addr)
}
}
else length = 1;
string = (charptr) malloc((size_t) length);
string = (charptr) xmalloc((size_t) length);
if (string == NULL) return(NULL);
start = 0;
comma = FALSE;
@ -2752,7 +2752,7 @@ charptr BitVector_Block_Read(wordptr addr, N_intptr length)
/* provide translation for independence of endian-ness: */
*length = size << FACTOR;
buffer = (charptr) malloc((size_t) ((*length)+1));
buffer = (charptr) xmalloc((size_t) ((*length)+1));
if (buffer == NULL) return(NULL);
target = buffer;
if (size > 0)

@ -286,7 +286,7 @@ ErrCode BitVector_Boot(void)
FACTOR = LOGBITS - 3; /* ld(BITS / 8) = ld(BITS) - ld(8) = ld(BITS) - 3 */
MSB = (LSB << MODMASK);
BITMASKTAB = (wordptr) malloc((size_t) (BITS << FACTOR));
BITMASKTAB = (wordptr) xmalloc((size_t) (BITS << FACTOR));
if (BITMASKTAB == NULL) return(ErrCode_Null);
@ -345,7 +345,7 @@ wordptr BitVector_Create(N_int bits, boolean clear) /* malloc */
size = BitVector_Size(bits);
mask = BitVector_Mask(bits);
bytes = (size + BIT_VECTOR_HIDDEN_WORDS) << FACTOR;
addr = (wordptr) malloc((size_t) bytes);
addr = (wordptr) xmalloc((size_t) bytes);
if (addr != NULL)
{
*addr++ = bits;
@ -426,7 +426,7 @@ wordptr BitVector_Resize(wordptr oldaddr, N_int bits) /* realloc */
else
{
bytes = (newsize + BIT_VECTOR_HIDDEN_WORDS) << FACTOR;
newaddr = (wordptr) malloc((size_t) bytes);
newaddr = (wordptr) xmalloc((size_t) bytes);
if (newaddr != NULL)
{
*newaddr++ = bits;
@ -1317,7 +1317,7 @@ charptr BitVector_to_Hex(wordptr addr)
length = bits >> 2;
if (bits AND 0x0003) length++;
string = (charptr) malloc((size_t) (length+1));
string = (charptr) xmalloc((size_t) (length+1));
if (string == NULL) return(NULL);
string += length;
*string = (N_char) '\0';
@ -1388,7 +1388,7 @@ charptr BitVector_to_Bin(wordptr addr)
charptr string;
length = bits_(addr);
string = (charptr) malloc((size_t) (length+1));
string = (charptr) xmalloc((size_t) (length+1));
if (string == NULL) return(NULL);
string += length;
*string = (N_char) '\0';
@ -1471,7 +1471,7 @@ charptr BitVector_to_Dec(wordptr addr)
length = (N_word) (bits / 3.3); /* digits = bits * ln(2) / ln(10) */
length += 2; /* compensate for truncating & provide space for minus sign */
result = (charptr) malloc((size_t) (length+1)); /* remember the '\0'! */
result = (charptr) xmalloc((size_t) (length+1)); /* remember the '\0'! */
if (result == NULL) return(NULL);
string = result;
sign = BitVector_Sign(addr);
@ -1743,7 +1743,7 @@ charptr BitVector_to_Enum(wordptr addr)
}
}
else length = 1;
string = (charptr) malloc((size_t) length);
string = (charptr) xmalloc((size_t) length);
if (string == NULL) return(NULL);
start = 0;
comma = FALSE;
@ -2752,7 +2752,7 @@ charptr BitVector_Block_Read(wordptr addr, N_intptr length)
/* provide translation for independence of endian-ness: */
*length = size << FACTOR;
buffer = (charptr) malloc((size_t) ((*length)+1));
buffer = (charptr) xmalloc((size_t) ((*length)+1));
if (buffer == NULL) return(NULL);
target = buffer;
if (size > 0)

Loading…
Cancel
Save