Skip to content

Commit

Permalink
latest
Browse files Browse the repository at this point in the history
  • Loading branch information
Steve Dekorte authored and Steve Dekorte committed Oct 21, 2009
1 parent 75b2211 commit 234337f
Show file tree
Hide file tree
Showing 10 changed files with 65 additions and 24 deletions.
9 changes: 8 additions & 1 deletion source/CHash.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ void CHash_show(CHash *self)
for(i = 0; i < self->size; i++) for(i = 0; i < self->size; i++)
{ {
CHashRecord *r = CRecords_recordAt_(self->records, i); CHashRecord *r = CRecords_recordAt_(self->records, i);
printf(" %p: %p %p\n", i, r->k, r->v); printf(" %i: %p %p\n", (int)i, r->k, r->v);
} }
} }


Expand Down Expand Up @@ -201,6 +201,13 @@ void CHash_removeKey_(CHash *self, void *k)
} }
} }


void CHash_clear(CHash *self)
{
memset(self->records, 0x0, self->size * sizeof(CHashRecord));
self->keyCount = 0;
CHash_shrinkIfNeeded(self);
}

size_t CHash_size(CHash *self) // actually the keyCount size_t CHash_size(CHash *self) // actually the keyCount
{ {
return self->keyCount; return self->keyCount;
Expand Down
1 change: 1 addition & 0 deletions source/CHash.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ BASEKIT_API void CHash_setHash2Func_(CHash *self, CHashHashFunc *f);
BASEKIT_API void CHash_setEqualFunc_(CHash *self, CHashEqualFunc *f); BASEKIT_API void CHash_setEqualFunc_(CHash *self, CHashEqualFunc *f);


BASEKIT_API void CHash_removeKey_(CHash *self, void *k); BASEKIT_API void CHash_removeKey_(CHash *self, void *k);
BASEKIT_API void CHash_clear(CHash *self);
BASEKIT_API size_t CHash_size(CHash *self); // actually the keyCount BASEKIT_API size_t CHash_size(CHash *self); // actually the keyCount


BASEKIT_API size_t CHash_memorySize(CHash *self); BASEKIT_API size_t CHash_memorySize(CHash *self);
Expand Down
2 changes: 1 addition & 1 deletion source/List.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ void List_print(const List *self)


for (i = 0; i < self->size; i ++) for (i = 0; i < self->size; i ++)
{ {
printf("%i: %p\n", i, (void *)self->items[i]); printf("%i: %p\n", (int)i, (void *)self->items[i]);
} }


printf("\n"); printf("\n");
Expand Down
2 changes: 1 addition & 1 deletion source/PointerHash.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ void PointerHash_show(PointerHash *self)
for(i = 0; i < self->size; i++) for(i = 0; i < self->size; i++)
{ {
PointerHashRecord *r = PointerHashRecords_recordAt_(self->records, i); PointerHashRecord *r = PointerHashRecords_recordAt_(self->records, i);
printf(" %p: %p %p\n", i, r->k, r->v); printf(" %i: %p %p\n", (int)i, r->k, r->v);
} }
} }


Expand Down
18 changes: 9 additions & 9 deletions source/UArray.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -255,8 +255,8 @@ UArray *UArray_clone(const UArray *self)
void UArray_show(const UArray *self) void UArray_show(const UArray *self)
{ {
printf("UArray_%p %s\t", (void *)self, CTYPE_name(self->itemType)); printf("UArray_%p %s\t", (void *)self, CTYPE_name(self->itemType));
printf("size: %i ", self->size); printf("size: %i ", (int)self->size);
printf("itemSize: %i ", self->itemSize); printf("itemSize: %i ", (int)self->itemSize);
printf("data: "); printf("data: ");
UArray_print(self); UArray_print(self);
printf("\n"); printf("\n");
Expand Down Expand Up @@ -885,13 +885,13 @@ void UArray_at_putAll_(UArray *self, size_t pos, const UArray *other)
//(&newChunk)->data == 0x0 || //(&newChunk)->data == 0x0 ||
(&insertChunk)->data == 0x0) (&insertChunk)->data == 0x0)
{ {
printf("oldChunk.data %p size %i\n", (void *)(&oldChunk)->data, oldChunk.size); printf("oldChunk.data %p size %i\n", (void *)(&oldChunk)->data, (int)oldChunk.size);
printf("newChunk.data %p size %i\n", (void *)(&newChunk)->data, newChunk.size); printf("newChunk.data %p size %i\n", (void *)(&newChunk)->data, (int)newChunk.size);
printf("insertChunk.data %p size %i\n", (void *)(&insertChunk)->data, insertChunk.size); printf("insertChunk.data %p size %i\n", (void *)(&insertChunk)->data, (int)insertChunk.size);
printf("originalSelfSize = %i\n", originalSelfSize); printf("originalSelfSize = %i\n", (int)originalSelfSize);
printf("self->size = %i\n", self->size); printf("self->size = %i\n", (int)self->size);
printf("other->size = %i\n", other->size); printf("other->size = %i\n", (int)other->size);
printf("pos = %i\n", pos); printf("pos = %i\n", (int)pos);
//exit(-1); //exit(-1);


oldChunk = UArray_stackRange(self, pos, chunkSize); oldChunk = UArray_stackRange(self, pos, chunkSize);
Expand Down
24 changes: 24 additions & 0 deletions source/UArray.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -442,6 +442,30 @@ BASEKIT_API void UArray_sortBy_(UArray *self, UArraySortCallback *cmp);
case CTYPE_float32_t: UARRAY_FOREACHTYPEASSIGN(self, i, v, code, float32_t); break;\ case CTYPE_float32_t: UARRAY_FOREACHTYPEASSIGN(self, i, v, code, float32_t); break;\
case CTYPE_float64_t: UARRAY_FOREACHTYPEASSIGN(self, i, v, code, float64_t); break;\ case CTYPE_float64_t: UARRAY_FOREACHTYPEASSIGN(self, i, v, code, float64_t); break;\
} }

#define UARRAY_FOREACHTYPEASSIGN_VALUE_UNUSED(self, i, code, TYPE)\
{\
size_t i;\
for(i = 0; i < self->size; i ++)\
{\
((TYPE *)self->data)[i] = code;\
}\
}

#define UARRAY_FOREACHASSIGN_VALUE_UNUSED(self, i, code)\
switch(self->itemType)\
{\
case CTYPE_uint8_t: UARRAY_FOREACHTYPEASSIGN_VALUE_UNUSED(self, i, code, uint8_t); break;\
case CTYPE_uint16_t: UARRAY_FOREACHTYPEASSIGN_VALUE_UNUSED(self, i, code, uint16_t); break;\
case CTYPE_uint32_t: UARRAY_FOREACHTYPEASSIGN_VALUE_UNUSED(self, i, code, uint32_t); break;\
case CTYPE_uint64_t: UARRAY_FOREACHTYPEASSIGN_VALUE_UNUSED(self, i, code, uint64_t); break;\
case CTYPE_int8_t: UARRAY_FOREACHTYPEASSIGN_VALUE_UNUSED(self, i, code, int8_t); break;\
case CTYPE_int16_t: UARRAY_FOREACHTYPEASSIGN_VALUE_UNUSED(self, i, code, int16_t); break;\
case CTYPE_int32_t: UARRAY_FOREACHTYPEASSIGN_VALUE_UNUSED(self, i, code, int32_t); break;\
case CTYPE_int64_t: UARRAY_FOREACHTYPEASSIGN_VALUE_UNUSED(self, i, code, int64_t); break;\
case CTYPE_float32_t: UARRAY_FOREACHTYPEASSIGN_VALUE_UNUSED(self, i, code, float32_t); break;\
case CTYPE_float64_t: UARRAY_FOREACHTYPEASSIGN_VALUE_UNUSED(self, i, code, float64_t); break;\
}


// ---------------------------- // ----------------------------


Expand Down
1 change: 1 addition & 0 deletions source/UArray_character.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@


#include "UArray.h" #include "UArray.h"
#include <math.h> #include <math.h>
#include <ctype.h>


// set // set


Expand Down
9 changes: 5 additions & 4 deletions source/UArray_math.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -58,22 +58,22 @@ void UArray_round(UArray *self)


void UArray_clear(UArray *self) void UArray_clear(UArray *self)
{ {
UARRAY_FOREACHASSIGN(self, i, v, 0); UARRAY_FOREACHASSIGN_VALUE_UNUSED(self, i, 0);
} }


void UArray_setItemsToLong_(UArray *self, long x) void UArray_setItemsToLong_(UArray *self, long x)
{ {
UARRAY_FOREACHASSIGN(self, i, v, x); UARRAY_FOREACHASSIGN_VALUE_UNUSED(self, i, x);
} }


void UArray_setItemsToDouble_(UArray *self, double x) void UArray_setItemsToDouble_(UArray *self, double x)
{ {
UARRAY_FOREACHASSIGN(self, i, v, x); UARRAY_FOREACHASSIGN_VALUE_UNUSED(self, i, x);
} }


void UArray_rangeFill(UArray *self) void UArray_rangeFill(UArray *self)
{ {
UARRAY_FOREACHASSIGN(self, i, v, i); UARRAY_FOREACHASSIGN_VALUE_UNUSED(self, i, i);
} }


void UArray_negate(const UArray *self) void UArray_negate(const UArray *self)
Expand Down Expand Up @@ -147,6 +147,7 @@ void UArray_divide_(UArray *self, const UArray *other)
double UArray_dotProduct_(const UArray *self, const UArray *other) double UArray_dotProduct_(const UArray *self, const UArray *other)
{ {
DUARRAY_OP(UARRAY_DOT, NULL, self, other); DUARRAY_OP(UARRAY_DOT, NULL, self, other);
return 0; // to keep compiler from annoying us
} }


// basic scalar math // basic scalar math
Expand Down
1 change: 1 addition & 0 deletions source/UArray_string.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <stdarg.h> #include <stdarg.h>
#include <stdio.h> #include <stdio.h>
#include <stddef.h> #include <stddef.h>
#include <ctype.h>


void UArray_append_(UArray *self, const UArray *other) void UArray_append_(UArray *self, const UArray *other)
{ {
Expand Down
22 changes: 14 additions & 8 deletions source/UArray_utf.c
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -126,7 +126,13 @@ int UArray_isMultibyte(const UArray *self)
{ {
if (self->encoding == CENCODING_UTF8) if (self->encoding == CENCODING_UTF8)
{ {
UARRAY_INTFOREACH(self, i, v, if (ismbchar((int)v)) return 1; ); size_t i, max = UArray_sizeInBytes(self);
const uint8_t *bytes = UArray_bytes(self);
for (i = 0; i < max; i ++)
{
if (UArray_SizeOfUTF8Char(bytes + i) > 1) return 1;
}
//UARRAY_INTFOREACH(self, i, v, if (ismbchar((int)v)) return 1; );
} }


return 0; return 0;
Expand All @@ -150,11 +156,11 @@ UArray *UArray_asNumberArrayString(const UArray *self)


if(UArray_isFloatType(self)) if(UArray_isFloatType(self))
{ {
sprintf(s, "%f", v); sprintf(s, "%f", (double)v);
} }
else else
{ {
sprintf(s, "%i", v); sprintf(s, "%i", (int)v);
} }


if(i != UArray_size(self) -1 ) strcat(s, ", "); if(i != UArray_size(self) -1 ) strcat(s, ", ");
Expand All @@ -172,11 +178,11 @@ UArray *UArray_asUTF8(const UArray *self)
UArray_setSize_(out, self->size * 4); UArray_setSize_(out, self->size * 4);


{ {
ConversionFlags options = lenientConversion; //ConversionFlags options = lenientConversion;
void *sourceStart = self->data; void *sourceStart = self->data;
void *sourceEnd = self->data + self->size * self->itemSize; //void *sourceEnd = self->data + self->size * self->itemSize;
UTF8 *targetStart = out->data; UTF8 *targetStart = out->data;
UTF8 *targetEnd = out->data + out->size * out->itemSize; //UTF8 *targetEnd = out->data + out->size * out->itemSize;
size_t outSize; size_t outSize;


switch(self->encoding) switch(self->encoding)
Expand Down Expand Up @@ -242,7 +248,7 @@ UArray *UArray_asUCS2(const UArray *self)


if ((numChars > 0) && (numChars > countedChars*2)) if ((numChars > 0) && (numChars > countedChars*2))
{ {
printf("UArray_asUCS2 error: numChars (%i) > countedChars (2*%i)\n", numChars, countedChars); printf("UArray_asUCS2 error: numChars (%i) > countedChars (2*%i)\n", (int)numChars, (int)countedChars);
printf("Exiting because we may have overwritten the usc2 decode output buffer."); printf("Exiting because we may have overwritten the usc2 decode output buffer.");
exit(-1); exit(-1);
} }
Expand All @@ -269,7 +275,7 @@ UArray *UArray_asUCS4(const UArray *self)


if ((numChars > 0) && (numChars > countedChars*2)) if ((numChars > 0) && (numChars > countedChars*2))
{ {
printf("UArray_asUCS4 error: numChars %i != countedChars %i\n", numChars, countedChars); printf("UArray_asUCS4 error: numChars %i != countedChars %i\n", (int)numChars, (int)countedChars);
exit(-1); exit(-1);
} }


Expand Down

0 comments on commit 234337f

Please sign in to comment.