~ubuntu-branches/ubuntu/utopic/bmf/utopic

« back to all changes in this revision

Viewing changes to dbdb.c

  • Committer: Package Import Robot
  • Author(s): Jari Aalto
  • Date: 2012-05-28 08:21:40 UTC
  • Revision ID: package-import@ubuntu.com-20120528082140-heidsbok0png68g1
Tags: 0.9.4-9
* debian/patches
  - (30): Revise. Instead of PATH_MAX allocate the exact amount of
    memory that is needed (FTBFS hurd; Closes: #674825). Patch thanks to
    Cyril Roelandt <tipecaml@gmail.com>.

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
#include "dbh.h"
19
19
#include "dbdb.h"
20
20
 
21
 
/* PATH_MAX */
22
 
#include <limits.h>
23
 
 
24
 
/*  PATH_MAX is only mandated by POSIX if there is a system limit for the
25
 
 *  maximum path length. This is not the case on GNU/Hurd.
26
 
 */
27
 
 
28
 
#ifndef PATH_MAX
29
 
#define PATH_MAX 5000
30
 
#endif
31
 
 
32
21
#ifdef HAVE_LIBDB
33
22
 
34
23
#define DBT_init( pdbt ) memset( pdbt, 0, sizeof(DBT) )
189
178
    DBT         key;
190
179
    DBT         val;
191
180
 
192
 
    char        szpath[PATH_MAX];
 
181
    char*       szpath;
193
182
 
194
183
    ptable = (dbtdb_t*)malloc( sizeof(dbtdb_t) );
195
184
    if( ptable == NULL )
205
194
    ptable->getcount = dbdb_table_getcount;
206
195
    ptable->dbp = NULL;
207
196
 
 
197
    szpath = malloc( strlen ( pthis->dir ) + strlen( table ) + 5 );
 
198
    if( szpath == NULL )
 
199
    {
 
200
        return NULL;
 
201
    }
208
202
    sprintf( szpath, "%s/%s.db", pthis->dir, table );
209
203
#if !defined(DB_VERSION_MAJOR)
210
204
    if( (dbp = dbopen( szpath, O_CREAT|O_RDWR, 0644, DB_BTREE, NULL)) == NULL )
252
246
 
253
247
bail:
254
248
    free( ptable );
 
249
    free( szpath );
255
250
    return NULL;
256
251
}
257
252