attempted fix for bson_ext on solaris (slyphon)

This commit is contained in:
Kyle Banker 2010-07-02 16:03:42 -04:00
parent 078372f869
commit a24448d911

View File

@ -141,7 +141,11 @@ static void write_utf8(buffer_t buffer, VALUE string, char check_null) {
* and raise an exception if not. */
/* TODO maybe we can use something more portable like vsnprintf instead
* of this hack. And share it with the Python extension ;) */
/* If we don't have ASPRINTF, there are two possibilities:
* either use _scprintf and _snprintf on for Windows or
* use snprintf for solaris. */
#ifndef HAVE_ASPRINTF
#ifdef _MSC_VER
#define INT2STRING(buffer, i) \
{ \
int vslength = _scprintf("%d", i) + 1; \
@ -149,6 +153,14 @@ static void write_utf8(buffer_t buffer, VALUE string, char check_null) {
_snprintf(*buffer, vslength, "%d", i); \
}
#else
#define INT2STRING(buffer, i) \
{ \
int vslength = snprintf(NULL, 0, "%d", i) + 1; \
*buffer = malloc(vslength); \
snprintf(*buffer, vslength, "%d", i); \
}
#endif
#else
#define INT2STRING(buffer, i) asprintf(buffer, "%d", i);
#endif