source: soft/giet_vm/giet_libs/string.h @ 788

Last change on this file since 788 was 781, checked in by alain, 9 years ago

Fixing two bugs:
1) In the string library: the strcpy() function must copy
the terminating NUL character in the destination buffer.
2) In the malloc library: the free() function must reset
the entry associated to the released buffer in the alloc[array].

  • Property svn:executable set to *
File size: 2.4 KB
Line 
1//////////////////////////////////////////////////////////////////////////////////
2// File     : string.h
3// Date     : 23/05/2013
4// Author   : Alexandre JOANNOU, Laurent LAMBERT
5// Copyright (c) UPMC-LIP6
6///////////////////////////////////////////////////////////////////////////////////
7
8#ifndef _STRING_H
9#define _STRING_H
10
11////////////////////////////////////////////////////////////////////////////////////////
12// This function copies the source string to the dest string, including the NUL
13// terminating character.
14// It returns a pointer on the dest string.
15////////////////////////////////////////////////////////////////////////////////////////
16char * strcpy(char * destination, const char * source);
17
18////////////////////////////////////////////////////////////////////////////////////////
19// The strncpy() function is similar to strcpy, except that at most n bytes of src
20// are copied. If there is no null byte among the first n bytes of src, the string
21// placed in dest will not be null terminated.
22////////////////////////////////////////////////////////////////////////////////////////
23char * strncpy(char * dest, const char * src, int n);
24
25////////////////////////////////////////////////////////////////////////////////////////
26// The strcmp() function compares the two strings s1 and s2.  It returns an integer
27// less than, equal to, or greater than zero if s1 is found, respectively, to be smaller
28// to match, or be greater than s2.
29////////////////////////////////////////////////////////////////////////////////////////
30int strcmp(const char * str1, const char * str2);
31
32////////////////////////////////////////////////////////////////////////////////////////
33// This function returns the number of characters in a string.
34// The terminating NULL character is not taken into account.
35////////////////////////////////////////////////////////////////////////////////////////
36int strlen(const char * str);
37
38////////////////////////////////////////////////////////////////////////////////////////
39// The strchr() function returns a pointer to the first occurrence of the character c
40// in the string s.
41////////////////////////////////////////////////////////////////////////////////////////
42char * strchr(const char * str, int c);
43
44#endif
45
46// Local Variables:
47// tab-width: 4
48// c-basic-offset: 4
49// c-file-offsets:((innamespace . 0)(inline-open . 0))
50// indent-tabs-mode: nil
51// End:
52// vim: filetype=c:expandtab:shiftwidth=4:tabstop=4:softtabstop=4
Note: See TracBrowser for help on using the repository browser.