Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Synchronet
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Main
Synchronet
Commits
ca614def
Commit
ca614def
authored
12 years ago
by
deuce
Browse files
Options
Downloads
Patches
Plain Diff
Add *_TO_ASTRING() which uses alloca() but takes a max buf size argument
and trucates there.
parent
7fd1d2c1
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/sbbs3/sbbs.h
+31
-1
31 additions, 1 deletion
src/sbbs3/sbbs.h
with
31 additions
and
1 deletion
src/sbbs3/sbbs.h
+
31
−
1
View file @
ca614def
...
...
@@ -128,7 +128,7 @@ extern int thread_suid_broken; /* NPTL is no longer broken */
(ret)[JSSTSpos]=(char)JSSTSstrval[JSSTSpos]; \
(ret)[*JSSTSlenptr]=0; \
} \
else JS_ReportError(cx, "Error alocating %lu bytes at %s:%d", (*JSSTSlenptr)+1, getfname(__FILE__), __LINE__); \
else JS_ReportError(cx, "Error al
l
ocating %lu bytes at %s:%d", (*JSSTSlenptr)+1, getfname(__FILE__), __LINE__); \
} \
} \
}
...
...
@@ -173,6 +173,36 @@ extern int thread_suid_broken; /* NPTL is no longer broken */
if(JS_IsExceptionPending(cx)) \
return JS_FALSE;
#define JSSTRING_TO_ASTRING(cx, str, ret, maxsize, lenptr) \
{ \
size_t *JSSTSlenptr=lenptr; \
size_t JSSTSlen; \
size_t JSSTSpos; \
const jschar *JSSTSstrval; \
\
if(JSSTSlenptr==NULL) \
JSSTSlenptr=&JSSTSlen; \
(ret)=NULL; \
if((str) != NULL) { \
if((JSSTSstrval=JS_GetStringCharsAndLength((cx), (str), JSSTSlenptr))) { \
if(*JSSTSlenptr >= maxsize) \
*JSSTSlenptr = maxsize-1; \
if(((ret)=(char *)alloca(*JSSTSlenptr+1))) { \
for(JSSTSpos=0; JSSTSpos<*JSSTSlenptr; JSSTSpos++) \
(ret)[JSSTSpos]=(char)JSSTSstrval[JSSTSpos]; \
(ret)[*JSSTSlenptr]=0; \
} \
else JS_ReportError(cx, "Error allocating %lu bytes on stack at %s:%d", (*JSSTSlenptr)+1, getfname(__FILE__), __LINE__); \
} \
} \
}
#define JSVALUE_TO_ASTRING(cx, val, ret, maxsize, lenptr) \
{ \
JSString *JSVTSstr=JS_ValueToString((cx), (val)); \
JSSTRING_TO_ASTRING((cx), JSVTSstr, (ret), (maxsize), (lenptr)); \
}
#define JSSTRING_TO_STRING(cx, str, ret, lenptr) \
{ \
size_t *JSSTSlenptr=lenptr; \
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment