Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop/holland01 #7

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 17 additions & 16 deletions base58.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,17 @@
#include <arpa/inet.h>
#else
#include <winsock2.h>
#ifdef _MSC_VER
#include <malloc.h>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There doesn't seem to be any malloc.h on at least Mingw cross-compilers.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll replace with an appropriate _MSC_VER check.


#include <stdio.h>
#endif
#endif

#include <stdbool.h>
#include <stddef.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h>

#include <sys/types.h>

Expand All @@ -41,26 +43,25 @@ typedef uint32_t b58_almostmaxint_t;
#define b58_almostmaxint_bits (sizeof(b58_almostmaxint_t) * 8)
static const b58_almostmaxint_t b58_almostmaxint_mask = ((((b58_maxint_t)1) << b58_almostmaxint_bits) - 1);

// MSVC 2017 doesn't support the GCC (and probably clang) extension
// for dynamic arrays in C
#ifdef _WIN32
// MSVC 2017 C99 doesn't support dynamic arrays in C
#ifdef _MSC_VER
#define b58_log_err(msg, ...) printf("[" __FUNCTION__ " - ERROR]: " msg, __VA_ARGS__)

#define b58_alloc_mem(type, name, count) \
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm honestly not sure what's up with the indentation of the escape slashes here. With invisibles in Atom turned on everything looks as if it's tabbed appropriately, and this is exactly how it looked before the push:

badformat

type *name = NULL; \
do { \
name = calloc(count, sizeof(type)); \
if (!name) { \
#define b58_alloc_mem(type, name, count) \
type *name = NULL; \
do { \
name = _malloca(count * sizeof(type)); \
if (!name) { \
b58_log_err("%s", "Could not allocate " #name); \
return false; \
} \
return false; \
} \
} while (0)

#define b58_free_mem(v) \
do { \
if ((v)) { \
free((v)); \
} \
#define b58_free_mem(v) \
do { \
if ((v)) { \
_freea((v)); \
} \
} while (0)
#else
#define b58_alloc_mem(type, name, count) type name[count]
Expand Down