Skip to content

Commit

Permalink
Update to version 1.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
HubTou committed Nov 5, 2022
1 parent 240276e commit 60c220d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ LIBRARY=pylists4c

MAJOR_VERSION=1
MINOR_VERSION=0
PATCH_VERSION=0
PATCH_VERSION=1

LIB=lib$(LIBRARY).a
SOLIB=lib$(LIBRARY).so
Expand Down
9 changes: 6 additions & 3 deletions src/debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
#include <pylists4c.h>
#include "global.h"

#define MAX_NAME_SIZE 80
#define BUFFER_SIZE (MAX_NAME_SIZE + 22) // 22 = '[' + 19 digits 64 bits long + ']' + '\0'

/******************************************************************************/
// FUNCTION: listDebug()
// Prints all LIST details to stderr
Expand All @@ -16,7 +19,7 @@ EXPORT void listDebug(LIST* pList, STRING name)
{
LIST* pElement = NULL;
long i = 0;
char subname[1024];
char subname[BUFFER_SIZE];
char* pCharacter;

pElement = pList;
Expand Down Expand Up @@ -56,9 +59,9 @@ EXPORT void listDebug(LIST* pList, STRING name)
case ETYPE_LIST:
fprintf(stderr, "%s (%s, %zu byte%s) --> @%p\n", (pElement -> pValue)?"see below":"[]", "LIST*", pElement -> size, (pElement -> size > 1)?"s":"", pElement -> pNext);
if (name == NULL)
snprintf(subname, 1024, "list[%ld]", i);
snprintf(subname, BUFFER_SIZE, "list[%ld]", i);
else
snprintf(subname, 1024, "%s[%ld]", name, i);
snprintf(subname, BUFFER_SIZE, "%.*s[%ld]", MAX_NAME_SIZE, name, i);
listDebug(pElement -> pValue, subname);
break;
case ETYPE_STRUCT: listDebugStruct(pElement -> pValue, pElement -> size); break;
Expand Down
6 changes: 4 additions & 2 deletions src/types/Struct.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ void (*listStringStruct)(STRING buffer, void* pStruct, size_t size) = listString
void (*listPrintStruct)(void* pStruct, size_t size) = listPrintStructByDefault;
void (*listDebugStruct)(void* pStruct, size_t size) = listDebugStructByDefault;

#define BUFFER_SIZE 4

/******************************************************************************/
// FUNCTION: listSetStructSize()
// Sets the size of a STRUCT you want to compare
Expand Down Expand Up @@ -64,7 +66,7 @@ EXPORT int listCompareStructReversed(const void *p1, const void *p2)
/******************************************************************************/
EXPORT void listStringStructByDefault(STRING buffer, void* pStruct, size_t size)
{
char hexa[4];
char hexa[BUFFER_SIZE]; // 2 hexadecimal digits + ' ' + '\0'

buffer[0] = 0;
for (size_t i = 0; i < size; i++)
Expand All @@ -73,7 +75,7 @@ EXPORT void listStringStructByDefault(STRING buffer, void* pStruct, size_t size)
#if ! (defined(_WIN32) || defined(_WIN64) )
strcat(buffer, hexa);
#else
strcat_s(buffer, 4, hexa);
strcat_s(buffer, BUFFER_SIZE, hexa);
#endif
}
}
Expand Down

0 comments on commit 60c220d

Please sign in to comment.