Last change
on this file since 444 was
444,
checked in by satin@…, 6 years ago
|
add newlib,libalmos-mkh, restructure shared_syscalls.h and mini-libc
|
File size:
658 bytes
|
Rev | Line | |
---|
[444] | 1 | /* Copyright (C) 2002 by Red Hat, Incorporated. All rights reserved. |
---|
| 2 | * |
---|
| 3 | * Permission to use, copy, modify, and distribute this software |
---|
| 4 | * is freely granted, provided that this notice is preserved. |
---|
| 5 | */ |
---|
| 6 | |
---|
| 7 | #include <argz.h> |
---|
| 8 | #include <errno.h> |
---|
| 9 | #include <sys/types.h> |
---|
| 10 | #include <string.h> |
---|
| 11 | #include <stdlib.h> |
---|
| 12 | |
---|
| 13 | error_t |
---|
| 14 | argz_add (char **argz, |
---|
| 15 | size_t *argz_len, |
---|
| 16 | const char *str) |
---|
| 17 | { |
---|
| 18 | int len_to_add = 0; |
---|
| 19 | size_t last = *argz_len; |
---|
| 20 | |
---|
| 21 | if (str == NULL) |
---|
| 22 | return 0; |
---|
| 23 | |
---|
| 24 | len_to_add = strlen(str) + 1; |
---|
| 25 | *argz_len += len_to_add; |
---|
| 26 | |
---|
| 27 | if(!(*argz = (char *)realloc(*argz, *argz_len))) |
---|
| 28 | return ENOMEM; |
---|
| 29 | |
---|
| 30 | memcpy(*argz + last, str, len_to_add); |
---|
| 31 | return 0; |
---|
| 32 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.