Skip to content

Commit

Permalink
FIx trimming for fixedlen chars
Browse files Browse the repository at this point in the history
  • Loading branch information
NielsLiisberg committed Feb 19, 2020
1 parent 7680ca6 commit f0a1e75
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
1 change: 1 addition & 0 deletions headers/ext/mem001.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
PVOID memAlloc (ULONG len);
void memFree (PVOID * p);
PUCHAR memStrDup (PUCHAR s);
PUCHAR memStrTrimDup(PUCHAR s);
PVOID memRealloc(PVOID * p, ULONG len);
PVOID memShare (PUCHAR path, ULONG len);
ULONG memSize (PVOID p);
Expand Down
17 changes: 17 additions & 0 deletions src/ext/mem001.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,23 @@ PUCHAR memStrDup(PUCHAR s)
return p;
}
// -------------------------------------------------------------
PUCHAR memStrTrimDup(PUCHAR s)
{
PUCHAR p;
PUCHAR t;
LONG len = 0;

if (s == NULL) return NULL;

for (t=s; *t ; t++) {
if (*t > ' ') len = (t - s) + 1;
}
p = memAlloc (len+1);
memcpy (p , s , len); // Copy the string including the zerotermination
*(p+len) = 0;
return p;
}
// -------------------------------------------------------------
PVOID memRealloc (PVOID * p, ULONG len)
{
PUCHAR oldMem = *p;
Expand Down
2 changes: 1 addition & 1 deletion src/noxdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -1706,7 +1706,7 @@ void jx_NodeSet (PJXNODE pNode , PUCHAR Value)
freeNodeValue(pNode);

if (Value) {
pNode->Value = memStrDup(Value);
pNode->Value = memStrTrimDup(Value);
}
}
// ---------------------------------------------------------------------------
Expand Down

0 comments on commit f0a1e75

Please sign in to comment.