Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
Slurm
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
tud-zih-energy
Slurm
Commits
33f29e9d
Commit
33f29e9d
authored
22 years ago
by
tewk
Browse files
Options
Downloads
Patches
Plain Diff
Added unpackmem routines that just copy memory from a message buffer to a buffer in a structure
parent
0097b1b6
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/common/pack.c
+27
-0
27 additions, 0 deletions
src/common/pack.c
src/common/pack.h
+10
-0
10 additions, 0 deletions
src/common/pack.h
with
37 additions
and
0 deletions
src/common/pack.c
+
27
−
0
View file @
33f29e9d
...
@@ -162,6 +162,33 @@ _unpackmem_ptr(char **valp, uint16_t *size_valp, void **bufp, int *lenp)
...
@@ -162,6 +162,33 @@ _unpackmem_ptr(char **valp, uint16_t *size_valp, void **bufp, int *lenp)
}
}
/*
* Given 'bufp' pointing to a network byte order 32-bit integer
* (size) and an arbitrary data string, return a pointer to the
* data string in 'valp'. Also return the sizes of 'valp' in bytes.
* Advance bufp and decrement lenp by 4 bytes (size of memory
* size records) plus the actual buffer size.
*/
void
_unpackmem
(
char
*
valp
,
uint16_t
*
size_valp
,
void
**
bufp
,
int
*
lenp
)
{
uint16_t
nl
;
memcpy
(
&
nl
,
*
bufp
,
sizeof
(
nl
));
*
size_valp
=
ntohs
(
nl
);
(
size_t
)
*
bufp
+=
sizeof
(
nl
);
*
lenp
-=
sizeof
(
nl
);
if
(
*
size_valp
>
0
)
{
memcpy
(
valp
,
*
bufp
,
*
size_valp
);
(
size_t
)
*
bufp
+=
*
size_valp
;
*
lenp
-=
*
size_valp
;
}
else
*
valp
=
0
;
}
/*
/*
* Given 'bufp' pointing to a network byte order 32-bit integer
* Given 'bufp' pointing to a network byte order 32-bit integer
* (size) and an arbitrary data string, return a pointer to the
* (size) and an arbitrary data string, return a pointer to the
...
...
This diff is collapsed.
Click to expand it.
src/common/pack.h
+
10
−
0
View file @
33f29e9d
...
@@ -32,6 +32,7 @@ void _packstrarray(char **valp, uint16_t size_val, void **bufp, int *lenp);
...
@@ -32,6 +32,7 @@ void _packstrarray(char **valp, uint16_t size_val, void **bufp, int *lenp);
void
_unpackstrarray
(
char
***
valp
,
uint16_t
*
size_val
,
void
**
bufp
,
int
*
lenp
);
void
_unpackstrarray
(
char
***
valp
,
uint16_t
*
size_val
,
void
**
bufp
,
int
*
lenp
);
void
_packmem
(
char
*
valp
,
uint16_t
size_val
,
void
**
bufp
,
int
*
lenp
);
void
_packmem
(
char
*
valp
,
uint16_t
size_val
,
void
**
bufp
,
int
*
lenp
);
void
_unpackmem
(
char
*
valp
,
uint16_t
*
size_valp
,
void
**
bufp
,
int
*
lenp
);
void
_unpackmem_ptr
(
char
**
valp
,
uint16_t
*
size_valp
,
void
**
bufp
,
int
*
lenp
);
void
_unpackmem_ptr
(
char
**
valp
,
uint16_t
*
size_valp
,
void
**
bufp
,
int
*
lenp
);
void
_unpackmem_xmalloc
(
char
**
valp
,
uint16_t
*
size_valp
,
void
**
bufp
,
int
*
lenp
);
void
_unpackmem_xmalloc
(
char
**
valp
,
uint16_t
*
size_valp
,
void
**
bufp
,
int
*
lenp
);
void
_unpackmem_malloc
(
char
**
valp
,
uint16_t
*
size_valp
,
void
**
bufp
,
int
*
lenp
);
void
_unpackmem_malloc
(
char
**
valp
,
uint16_t
*
size_valp
,
void
**
bufp
,
int
*
lenp
);
...
@@ -78,6 +79,15 @@ void _unpackmem_malloc(char **valp, uint16_t *size_valp, void **bufp, int *lenp)
...
@@ -78,6 +79,15 @@ void _unpackmem_malloc(char **valp, uint16_t *size_valp, void **bufp, int *lenp)
_packmem(valp,(uint16_t)size_val,bufp,lenp); \
_packmem(valp,(uint16_t)size_val,bufp,lenp); \
} while (0)
} while (0)
#define unpackmem(valp,size_valp,bufp,lenp) do { \
assert(valp != NULL); \
assert(sizeof(size_valp) == sizeof(uint16_t *));\
assert((bufp) != NULL && *(bufp) != NULL); \
assert((lenp) != NULL); \
assert(*(lenp) >= sizeof(uint16_t)); \
_unpackmem(valp,(uint16_t *)size_valp,bufp,lenp); \
} while (0)
#define packstr(str,bufp,lenp) do { \
#define packstr(str,bufp,lenp) do { \
uint32_t _size; \
uint32_t _size; \
_size = (uint32_t)(str ? strlen(str)+1 : 0); \
_size = (uint32_t)(str ? strlen(str)+1 : 0); \
...
...
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