Add git2cl from repo.or.cz as a submodule in tools/git2cl.
[fw/openocd] / src / helper / membuf.c
index 1efb12b60931ceb3d5acb5597c900bdc0d763a7e..766364a88e7066dbdba5281927012c1f1c9fbe49 100644 (file)
@@ -20,7 +20,7 @@
 
 #include <stdio.h>
 #include <stdarg.h>
-#include <malloc.h>
+#include <stdlib.h>
 #include <string.h>
 
 #include "membuf.h"
@@ -29,7 +29,7 @@ struct membuf {
     // buflen is alway "+1" bigger then
     // what is shown here, the +1 is for
     // the NULL string terminator
-#define DEFAULT_BUFSIZE 100    
+#define DEFAULT_BUFSIZE 100
     size_t maxlen; // allocated size
     size_t curlen; // where we are inserting at
     char *_strtoklast;
@@ -40,7 +40,7 @@ struct membuf {
 #define space_avail(pBuf)  (pBuf->maxlen - pBuf->curlen)
 #define dataend(pBuf)      (((char *)(pBuf->buf)) + pBuf->curlen)
 
-size_t 
+size_t
 membuf_len(struct membuf *pBuf)
 {
     return pBuf->curlen;
@@ -58,14 +58,16 @@ membuf_strtok(struct membuf *pBuf, const char *sep, void **pLast)
     if (pBuf) {
        pBuf->_strtoklast = NULL;
        *pLast = pBuf;
-       return strtok_r(((char *)(pBuf->buf)), sep, &(pBuf->_strtoklast));
+       // this should be "strtok_r()" but windows lacks */
+       return strtok(((char *)(pBuf->buf)), sep);
     } else {
        // recover our pBuf
        pBuf = *((struct membuf **)(pLast));
-       return strtok_r(NULL, sep, &(pBuf->_strtoklast));
+       // this should be "strtok_r()" but windows lacks */
+       return strtok( NULL, sep);
     }
 }
-       
+
 
 
 struct membuf *
@@ -161,7 +163,7 @@ membuf_vsprintf(struct membuf *pBuf, const char *fmt, va_list ap)
        // do work
        r = vsnprintf(dataend(pBuf),
                       sa,
-                      fmt, 
+                      fmt,
                       ap);
        if ((r > 0) && (((size_t)(r)) < sa)) {
            // Success!