Skip to content

Commit

Permalink
Replace strndup() with our own function to make it work with MinGW.
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Preuss committed Apr 29, 2016
1 parent e129e64 commit 82eab2b
Showing 1 changed file with 22 additions and 11 deletions.
33 changes: 22 additions & 11 deletions src/plugins/parsers/swift/swift940.c
Expand Up @@ -7,7 +7,6 @@
* Please see toplevel file COPYING for license details *
***************************************************************************/


#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
Expand All @@ -33,10 +32,29 @@
/* #define ENABLE_FULL_SEPA_LOG */



#define CENTURY_CUTOFF_YEAR 79



static char *my_strndup(const char *src, size_t n) {
int len;

len=strlen(src);
if (len<n)
return strdup(src);
else {
char *cpy;

cpy=(char*) malloc(n+1);
assert(cpy);
memmove(cpy, src, n);
cpy[n]=0;
return cpy;
}
}



int AHB_SWIFT__SetCharValue(GWEN_DB_NODE *db,
uint32_t flags,
const char *name,
Expand Down Expand Up @@ -306,7 +324,7 @@ int AHB_SWIFT940_Parse_86(const AHB_SWIFT_TAG *tg,
if (tagLen>0) {
char *sCopyPayload;

sCopyPayload=strndup(sPayload, tagLen);
sCopyPayload=my_strndup(sPayload, tagLen);
GWEN_DB_SetCharValue(dbSepaTags, GWEN_DB_FLAGS_DEFAULT, sIdentifier, sCopyPayload);
free(sCopyPayload);
realSepaTagCount++;
Expand All @@ -320,7 +338,7 @@ int AHB_SWIFT940_Parse_86(const AHB_SWIFT_TAG *tg,
if (tagLen>0) {
char *sCopyPayload;

sCopyPayload=strndup(sLastTagStart, tagLen);
sCopyPayload=my_strndup(sLastTagStart, tagLen);
GWEN_DB_SetCharValue(dbSepaTags, GWEN_DB_FLAGS_DEFAULT, "_purpose", sCopyPayload);
free(sCopyPayload);
}
Expand Down Expand Up @@ -1332,10 +1350,3 @@ int AHB_SWIFT940_Import(AHB_SWIFT_TAG_LIST *tl,
return 0;
}








0 comments on commit 82eab2b

Please sign in to comment.