PIPS
strndup.c File Reference
#include <config.h>
#include <string.h>
#include <stdlib.h>
+ Include dependency graph for strndup.c:

Go to the source code of this file.

Functions

char * strndup (char const *s, size_t n)
 A replacement function, for systems that lack strndup. More...
 

Function Documentation

◆ strndup()

char* strndup ( char const *  s,
size_t  n 
)

A replacement function, for systems that lack strndup.

Copyright (C) 1996-1998, 2001-2003, 2005-2007, 2009-2014 Free Software Foundation, Inc.

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, see http://www.gnu.org/licenses/.

Definition at line 26 of file strndup.c.

27 {
28  size_t len = strnlen (s, n);
29  char *new = malloc (len + 1);
30 
31  if (new == NULL)
32  return NULL;
33 
34  new[len] = '\0';
35  return memcpy (new, s, len);
36 }
void * malloc(YYSIZE_T)
size_t strnlen(const char *string, size_t maxlen)
Find the length of STRING, but scan at most MAXLEN characters.
Definition: strnlen.c:26

References malloc(), and strnlen().

Referenced by add_new_module_from_text(), clean_up_sequences_rewrite(), cstrsplit(), do_slightly_rename_entities(), expression_string_constant(), gather_grid_dim(), get_main_entity_name(), init_cost_table(), local_name_to_scope(), module_entity_to_compilation_unit_entity(), nth_path(), outliner_compilation_unit(), outliner_file(), outliner_independent(), pips_filename(), and sesam_buffer_to_server_entity().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: