OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [newlib-1.17.0/] [newlib/] [libc/] [argz/] [argz_add.c] - Blame information for rev 326

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 148 jeremybenn
/* 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
_DEFUN (argz_add, (argz, argz_len, str),
15
       char **argz _AND
16
       size_t *argz_len _AND
17
       const char *str)
18
{
19
  int len_to_add = 0;
20
  size_t last = *argz_len;
21
 
22
  if (str == NULL)
23
    return 0;
24
 
25
  len_to_add = strlen(str) + 1;
26
  *argz_len += len_to_add;
27
 
28
  if(!(*argz = (char *)realloc(*argz, *argz_len)))
29
    return ENOMEM;
30
 
31
  memcpy(*argz + last, str, len_to_add);
32
  return 0;
33
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.