Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
e3-require
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
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
Code review analytics
Issue 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
ESS EPICS Environment
wrappers
e3-require
Commits
2391ec9c
Commit
2391ec9c
authored
9 years ago
by
Dirk Zimoch
Browse files
Options
Downloads
Patches
Plain Diff
added helper functions unavailable in vxWorks
parent
e0f45e09
No related branches found
No related tags found
1 merge request
!7
Submodule merge
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
asprintf.c
+34
-0
34 additions, 0 deletions
asprintf.c
asprintf.h
+12
-0
12 additions, 0 deletions
asprintf.h
strdup.c
+22
-0
22 additions, 0 deletions
strdup.c
strdup.h
+11
-0
11 additions, 0 deletions
strdup.h
with
79 additions
and
0 deletions
asprintf.c
0 → 100644
+
34
−
0
View file @
2391ec9c
#include
<stdio.h>
#include
<stdlib.h>
#include
"asprintf.h"
int
vasprintf
(
char
**
pbuffer
,
const
char
*
format
,
va_list
ap
)
{
va_list
ap2
;
int
len
;
FILE
*
f
;
/* print to null device to get required buffer length */
f
=
fopen
(
"/null"
,
"w"
);
if
(
f
==
NULL
)
return
-
1
;
__va_copy
(
ap2
,
ap
);
len
=
vfprintf
(
f
,
format
,
ap2
);
va_end
(
ap2
);
fclose
(
f
);
if
(
len
<
0
)
return
len
;
*
pbuffer
=
malloc
(
len
+
1
);
if
(
*
pbuffer
==
NULL
)
return
-
1
;
return
vsprintf
(
*
pbuffer
,
format
,
ap
);
}
int
asprintf
(
char
**
pbuffer
,
const
char
*
format
,
...)
{
va_list
ap
;
int
len
;
va_start
(
ap
,
format
);
len
=
vasprintf
(
pbuffer
,
format
,
ap
);
va_end
(
ap
);
return
len
;
}
This diff is collapsed.
Click to expand it.
asprintf.h
0 → 100644
+
12
−
0
View file @
2391ec9c
#ifndef asprintf_h
#define asprintf_h
#ifdef __cplusplus
extern
"C"
{
#endif
#include
<stdarg.h>
int
asprintf
(
char
**
pbuffer
,
const
char
*
format
,
...)
__attribute__
((
format
(
printf
,
2
,
3
)));
int
vasprintf
(
char
**
pbuffer
,
const
char
*
format
,
va_list
ap
)
__attribute__
((
format
(
printf
,
2
,
0
)));
#ifdef __cplusplus
}
#endif
#endif
This diff is collapsed.
Click to expand it.
strdup.c
0 → 100644
+
22
−
0
View file @
2391ec9c
#include
<string.h>
#include
<stdlib.h>
char
*
strdup
(
const
char
*
s
)
{
char
*
d
=
malloc
(
strlen
(
s
)
+
1
);
if
(
d
)
strcpy
(
d
,
s
);
return
d
;
}
char
*
strndup
(
const
char
*
s
,
size_t
n
)
{
size_t
l
;
char
*
d
;
l
=
strlen
(
s
);
if
(
n
>
l
)
n
=
l
;
d
=
malloc
(
n
+
1
);
strncpy
(
d
,
s
,
l
);
d
[
n
]
=
0
;
return
d
;
}
This diff is collapsed.
Click to expand it.
strdup.h
0 → 100644
+
11
−
0
View file @
2391ec9c
#ifndef strdup_h
#define strdup_h
#ifdef __cplusplus
extern
"C"
{
#endif
char
*
strdup
(
const
char
*
s
);
char
*
strndup
(
const
char
*
s
,
size_t
n
);
#ifdef __cplusplus
}
#endif
#endif
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