ext/mathematical/mtex2MML/deps/uthash/utstring.h in mathematical-1.5.12 vs ext/mathematical/mtex2MML/deps/uthash/utstring.h in mathematical-1.6.0
- old
+ new
@@ -1,7 +1,7 @@
/*
-Copyright (c) 2008-2014, Troy D. Hanson http://troydhanson.github.com/uthash/
+Copyright (c) 2008-2016, Troy D. Hanson http://troydhanson.github.com/uthash/
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
@@ -24,11 +24,11 @@
/* a dynamic string implementation using macros
*/
#ifndef UTSTRING_H
#define UTSTRING_H
-#define UTSTRING_VERSION 1.9.9
+#define UTSTRING_VERSION 2.0.1
#ifdef __GNUC__
#define _UNUSED_ __attribute__ ((__unused__))
#else
#define _UNUSED_
@@ -36,32 +36,37 @@
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <stdarg.h>
+
+#ifndef oom
#define oom() exit(-1)
+#endif
typedef struct {
char *d;
size_t n; /* allocd size */
size_t i; /* index of first unused byte */
} UT_string;
#define utstring_reserve(s,amt) \
do { \
if (((s)->n - (s)->i) < (size_t)(amt)) { \
- (s)->d = (char*)realloc((s)->d, (s)->n + amt); \
- if ((s)->d == NULL) oom(); \
- (s)->n += amt; \
+ char *utstring_tmp = (char*)realloc( \
+ (s)->d, (s)->n + (amt)); \
+ if (utstring_tmp == NULL) oom(); \
+ (s)->d = utstring_tmp; \
+ (s)->n += (amt); \
} \
} while(0)
#define utstring_init(s) \
do { \
(s)->n = 0; (s)->i = 0; (s)->d = NULL; \
utstring_reserve(s,100); \
- (s)->d[0] = '\0'; \
+ (s)->d[0] = '\0'; \
} while(0)
#define utstring_done(s) \
do { \
if ((s)->d != NULL) free((s)->d); \
@@ -96,14 +101,14 @@
(s)->d[0] = '\0'; \
} while(0)
#define utstring_bincpy(s,b,l) \
do { \
- utstring_reserve((s),(l)+1); \
+ utstring_reserve((s),(l)+1); \
if (l) memcpy(&(s)->d[(s)->i], b, l); \
- (s)->i += l; \
- (s)->d[(s)->i]='\0'; \
+ (s)->i += (l); \
+ (s)->d[(s)->i]='\0'; \
} while(0)
#define utstring_concat(dst,src) \
do { \
utstring_reserve((dst),((src)->i)+1); \
@@ -117,10 +122,10 @@
#define utstring_body(s) ((s)->d)
_UNUSED_ static void utstring_printf_va(UT_string *s, const char *fmt, va_list ap) {
int n;
va_list cp;
- while (1) {
+ for (;;) {
#ifdef _WIN32
cp = ap;
#else
va_copy(cp, ap);
#endif