mirror of
https://github.com/netwide-assembler/nasm
synced 2026-08-26 16:23:04 -04:00
SAA: add saa_wcstring()
Add saa_wcstring() to write a C string (a string including final NUL) to an SAA, and return the number of bytes written. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
This commit is contained in:
parent
d00d8c6ac3
commit
40f0a7495a
2 changed files with 15 additions and 1 deletions
|
|
@ -70,6 +70,7 @@ struct SAA *saa_init(size_t elem_len); /* 1 == byte */
|
|||
void saa_free(struct SAA *);
|
||||
void *saa_wstruct(struct SAA *); /* return a structure of elem_len */
|
||||
void saa_wbytes(struct SAA *, const void *, size_t); /* write arbitrary bytes */
|
||||
size_t saa_wcstring(struct SAA *s, const char *str); /* write a C string */
|
||||
void saa_rewind(struct SAA *); /* for reading from beginning */
|
||||
void *saa_rstruct(struct SAA *); /* return NULL on EOA */
|
||||
const void *saa_rbytes(struct SAA *, size_t *); /* return 0 on EOA */
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
/* ----------------------------------------------------------------------- *
|
||||
*
|
||||
* Copyright 1996-2009 The NASM Authors - All Rights Reserved
|
||||
* Copyright 1996-2017 The NASM Authors - All Rights Reserved
|
||||
* See the file AUTHORS included with the NASM distribution for
|
||||
* the specific copyright holders.
|
||||
*
|
||||
|
|
@ -149,6 +149,19 @@ void saa_wbytes(struct SAA *s, const void *data, size_t len)
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Writes a string, *including* the final null, to the specified SAA,
|
||||
* and return the number of bytes written.
|
||||
*/
|
||||
size_t saa_wcstring(struct SAA *s, const char *str)
|
||||
{
|
||||
size_t bytes = strlen(str) + 1;
|
||||
|
||||
saa_wbytes(s, str, bytes);
|
||||
|
||||
return bytes;
|
||||
}
|
||||
|
||||
void saa_rewind(struct SAA *s)
|
||||
{
|
||||
s->rblk = s->blk_ptrs;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue