~ubuntu-branches/ubuntu/saucy/libpri/saucy

« back to all changes in this revision

Viewing changes to copy_string.c

  • Committer: Bazaar Package Importer
  • Author(s): Mark Purcell
  • Date: 2005-12-07 21:25:46 UTC
  • mfrom: (1.2.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20051207212546-lv02jlyw3pm9ho0q
Tags: 1.2.1-1
* New upstream release
* Disable bristuff for new upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * libpri: An implementation of Primary Rate ISDN
 
3
 *
 
4
 * Written by Mark Spencer <markster@digium.com>
 
5
 *
 
6
 * Copyright (C) 2005, Digium
 
7
 * All Rights Reserved.
 
8
 *
 
9
 * This program is free software; you can redistribute it and/or modify
 
10
 * it under the terms of the GNU General Public License as published by
 
11
 * the Free Software Foundation; either version 2 of the License, or
 
12
 * (at your option) any later version.
 
13
 * 
 
14
 * This program is distributed in the hope that it will be useful,
 
15
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
16
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
17
 * GNU General Public License for more details.
 
18
 * 
 
19
 * You should have received a copy of the GNU General Public License
 
20
 * along with this program; if not, write to the Free Software
 
21
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 
 
22
 *
 
23
 */
 
24
 
 
25
#include <string.h>
 
26
#include <unistd.h>
 
27
#include <stdlib.h>
 
28
 
 
29
#include "compiler.h"
 
30
#include "libpri.h"
 
31
#include "pri_internal.h"
 
32
 
 
33
void libpri_copy_string(char *dst, const char *src, size_t size)
 
34
{
 
35
        while (*src && size) {
 
36
                *dst++ = *src++;
 
37
                size--;
 
38
        }
 
39
        if (__builtin_expect(!size, 0))
 
40
                dst--;
 
41
        *dst = '\0';
 
42
}