~ubuntu-branches/ubuntu/trusty/speech-dispatcher/trusty-proposed

« back to all changes in this revision

Viewing changes to src/server/alloc.c

  • Committer: Package Import Robot
  • Author(s): Luke Yelavich, Samuel Thibault, Luke Yelavich, Jason White, David Henningsson
  • Date: 2013-11-11 16:38:46 UTC
  • mfrom: (1.1.19)
  • Revision ID: package-import@ubuntu.com-20131111163846-lvu37ypp5sy9z5so
Tags: 0.8-0ubuntu1
[ Samuel Thibault ]
* debian/control: Set libspeechd2 multi-arch: same.
* debian/rules: Set multiarch libdir.
* debian/libspeechd-dev.install,libspeechd2.install,
  speech-dispatcher.install: Use multiarch libdir.
* Do not depend on dpkg | install-info, now that we use the install-info
  trigger.
* Bump Standards-Version to 3.9.5.
* Bump dotconf dependency to >= 1.3.

[ Luke Yelavich ]
* New upstream release
* debian/patches/infinite-loop.patch: Refreshed
* Dropped patches:
  - debian/patches/build-doc.patch
  - debian/patches/procname.patch
  - debian/patches/paths+files.patch
  - debian/patches/pthread.patch
* Add libltdl-dev and intltool to build-depends
* Update packaging for speech-dispatcher python 3 bindings.
* Move speech-dispatcher modules to an architecture independant dir, since
  modules can be written in any language, and i386 only modules can be
  used on amd64 systems
* Create separate audio plugins package
* Convert to debhelper 7+ packaging.
* Use dh-autoreconf to handle autotools file rebuilds.
* Update standards version to 3.9.3.
* Add X-Python-Version related fields to debian/control.
* Patch in the speech-dispatcher-cs.texi file since it was forgotten in the
  0.8 tarball
* Add translations to speech-dispatcher
* Merge from debian unreleased git.  Remaining changes:
  - Moved the flite output module to a separate package, and added
    it to suggests, we don't want flite on the Ubuntu CD image
  - Don't build depend on libaudio-dev or libao-dev, Ubuntu CD size is an
    issue, every little bit helps
  - debian/gbp.conf: Adjust for the Ubuntu git branch
  - Python3-speechd needs to conflict against python-speechd

[ Jason White ]
* Raise level of subsection in fdl.texi to correct document structure.

[ David Henningsson ]
* debian/patches/pulse-default-latency.patch:
  Default to 20 ms latency instead of 1 ms latency (LP: #1208826)

[ Luke Yelavich ]
* spd_audio: Expose dlopened library's symbols to libs it loads. Thanks to
  Christopher Brannon <chris@the-brannons.com> for the patch, taken from
  the speech-dispatcher mailing list.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
 
 
2
#ifdef HAVE_CONFIG_H
 
3
#include <config.h>
 
4
#endif
 
5
 
2
6
#include "alloc.h"
3
7
 
4
 
void*
5
 
spd_malloc(size_t bytes)
6
 
{
7
 
        void *mem;
8
 
 
9
 
        mem = malloc(bytes);
10
 
        if(mem == NULL) FATAL("Can't allocate memmory.\n");
11
 
 
12
 
        return mem;
13
 
}
14
 
 
15
 
void*
16
 
spd_realloc(void *ptr, size_t bytes)
17
 
{
18
 
        void *mem;
19
 
 
20
 
        mem = realloc(ptr, bytes);
21
 
        if(mem == NULL) FATAL("Can't allocate memmory.\n");
22
 
 
23
 
        return mem;
24
 
}
25
 
 
26
 
void
27
 
spd_free(void* data)
28
 
{
29
 
    if (data != NULL) free(data);
30
 
}
31
 
 
32
 
char*
33
 
spd_strdup(char* string)
34
 
{
35
 
    char *newstr;
36
 
    
37
 
    if (string == NULL) return NULL;
38
 
 
39
 
    newstr = strdup(string);
40
 
    if (newstr == NULL) 
41
 
        FATAL("Can't duplicate a string of characters, not enough memmory");
42
 
 
43
 
    return newstr;
44
 
}
45
 
 
46
 
TSpeechDQueue* 
47
 
speechd_queue_alloc()
48
 
{
49
 
        TSpeechDQueue *new;
50
 
        
51
 
        new = spd_malloc(sizeof(TSpeechDQueue));
52
 
 
53
 
        /* Initialize all the queues to be empty */
54
 
        new->p1 = NULL;
55
 
        new->p2 = NULL;
56
 
        new->p3 = NULL;
57
 
        new->p4 = NULL;
58
 
        new->p5 = NULL;
59
 
 
60
 
        return(new);
61
 
}
62
 
 
63
 
TFDSetElement
64
 
spd_fdset_copy(TFDSetElement old)
65
 
{
66
 
    TFDSetElement new;
67
 
 
68
 
    new = old;
69
 
    new.language = spd_strdup(old.language);
70
 
    new.synthesis_voice = spd_strdup(old.synthesis_voice);
71
 
    new.client_name = spd_strdup(old.client_name);
72
 
    new.output_module = spd_strdup(old.output_module);
73
 
    new.index_mark = spd_strdup(old.index_mark);
74
 
    new.audio_output_method = spd_strdup(old.audio_output_method);
75
 
    new.audio_oss_device = spd_strdup(old.audio_oss_device);
76
 
    new.audio_alsa_device = spd_strdup(old.audio_alsa_device);
77
 
    new.audio_nas_server = spd_strdup(old.audio_nas_server);
78
 
    new.audio_pulse_server = spd_strdup(old.audio_pulse_server);
79
 
 
80
 
    return new;
81
 
    
82
 
    
83
 
}
84
 
 
85
 
TSpeechDMessage*
86
 
spd_message_copy(TSpeechDMessage *old)
87
 
{
88
 
        TSpeechDMessage* new = NULL;
89
 
 
90
 
        if (old == NULL) return NULL;
91
 
 
92
 
        new = (TSpeechDMessage *) spd_malloc(sizeof(TSpeechDMessage));
 
8
TFDSetElement spd_fdset_copy(TFDSetElement old)
 
9
{
 
10
        TFDSetElement new;
 
11
 
 
12
        new = old;
 
13
        new.msg_settings.voice.language =
 
14
            g_strdup(old.msg_settings.voice.language);
 
15
        new.msg_settings.voice.name = g_strdup(old.msg_settings.voice.name);
 
16
        new.client_name = g_strdup(old.client_name);
 
17
        new.output_module = g_strdup(old.output_module);
 
18
        new.index_mark = g_strdup(old.index_mark);
 
19
        new.audio_output_method = g_strdup(old.audio_output_method);
 
20
        new.audio_oss_device = g_strdup(old.audio_oss_device);
 
21
        new.audio_alsa_device = g_strdup(old.audio_alsa_device);
 
22
        new.audio_nas_server = g_strdup(old.audio_nas_server);
 
23
        new.audio_pulse_server = g_strdup(old.audio_pulse_server);
 
24
 
 
25
        return new;
 
26
 
 
27
}
 
28
 
 
29
TSpeechDMessage *spd_message_copy(TSpeechDMessage * old)
 
30
{
 
31
        TSpeechDMessage *new = NULL;
 
32
 
 
33
        if (old == NULL)
 
34
                return NULL;
 
35
 
 
36
        new = (TSpeechDMessage *) g_malloc(sizeof(TSpeechDMessage));
93
37
 
94
38
        *new = *old;
95
 
        new->buf = spd_malloc((old->bytes+1) * sizeof(char));
 
39
        new->buf = g_malloc((old->bytes + 1) * sizeof(char));
96
40
        memcpy(new->buf, old->buf, old->bytes);
97
 
        new->buf[new->bytes] = 0;       
98
 
        new->settings = spd_fdset_copy(old->settings); 
 
41
        new->buf[new->bytes] = 0;
 
42
        new->settings = spd_fdset_copy(old->settings);
99
43
 
100
44
        return new;
101
45
}
102
46
 
103
 
void 
104
 
mem_free_fdset(TFDSetElement *fdset)
105
 
{
106
 
    /* Don't forget that only these items are filled in
107
 
       in a TSpeechDMessage */
108
 
    spd_free(fdset->client_name);
109
 
    spd_free(fdset->language);
110
 
    spd_free(fdset->synthesis_voice);
111
 
    spd_free(fdset->output_module);
112
 
    spd_free(fdset->index_mark);
113
 
    spd_free(fdset->audio_output_method);
114
 
    spd_free(fdset->audio_oss_device);
115
 
    spd_free(fdset->audio_alsa_device);
116
 
    spd_free(fdset->audio_nas_server);
117
 
    spd_free(fdset->audio_pulse_server);
118
 
}
119
 
 
120
 
void
121
 
mem_free_message(TSpeechDMessage *msg)
122
 
{
123
 
    if (msg == NULL) return;
124
 
    spd_free(msg->buf);
125
 
    mem_free_fdset(&(msg->settings));
126
 
    spd_free(msg);
127
 
}
128
 
 
129
 
 
 
47
void mem_free_fdset(TFDSetElement * fdset)
 
48
{
 
49
        /* Don't forget that only these items are filled in
 
50
           in a TSpeechDMessage */
 
51
        g_free(fdset->client_name);
 
52
        g_free(fdset->msg_settings.voice.language);
 
53
        g_free(fdset->msg_settings.voice.name);
 
54
        g_free(fdset->output_module);
 
55
        g_free(fdset->index_mark);
 
56
        g_free(fdset->audio_output_method);
 
57
        g_free(fdset->audio_oss_device);
 
58
        g_free(fdset->audio_alsa_device);
 
59
        g_free(fdset->audio_nas_server);
 
60
        g_free(fdset->audio_pulse_server);
 
61
}
 
62
 
 
63
void mem_free_message(TSpeechDMessage * msg)
 
64
{
 
65
        if (msg == NULL)
 
66
                return;
 
67
        g_free(msg->buf);
 
68
        mem_free_fdset(&(msg->settings));
 
69
        g_free(msg);
 
70
}