]> granicus.if.org Git - php/commitdiff
emalloc never returns 0, so we can simplify the code paths.
authorSascha Schumann <sas@php.net>
Wed, 6 Nov 2002 17:59:03 +0000 (17:59 +0000)
committerSascha Schumann <sas@php.net>
Wed, 6 Nov 2002 17:59:03 +0000 (17:59 +0000)
also replace ecalloc with emalloc+memset, so that the latter can be inlined.

ext/dba/dba.c
ext/dba/dba_cdb.c
ext/dba/dba_db2.c
ext/dba/dba_db3.c
ext/dba/dba_dbm.c
ext/dba/dba_flatfile.c
ext/dba/dba_gdbm.c
ext/dba/dba_ndbm.c

index d68a291f577b87fd503edab97445036272085f41..8213166afdd3a1efc707287bdf2144f9867bbf6a 100644 (file)
@@ -369,12 +369,12 @@ static void php_dba_open(INTERNAL_FUNCTION_PARAMETERS, int persistent)
                        RETURN_FALSE;
        }
                        
-       info = ecalloc(sizeof(dba_info), 1);
+       info = emalloc(sizeof(dba_info));
+       memset(info, 0, sizeof(dba_info));
        info->path = estrdup(Z_STRVAL_PP(args[0]));
        info->mode = modenr;
        info->argc = ac - 3;
        info->argv = args + 3;
-       /* info->hnd is NULL here */
 
        if (hptr->open(info, &error TSRMLS_CC) != SUCCESS) {
                dba_close(info TSRMLS_CC);
index eac2576aec37c9b26e4ee0ad9f9812448dcba0be..87a96e8dca0b29a6f851a238cf7c68cef570c71a 100644 (file)
@@ -104,17 +104,8 @@ DBA_OPEN_FUNC(cdb)
                        return FAILURE;
        }
 
-       cdb = ecalloc(sizeof(dba_cdb), 1);
-       if (!cdb) {
-       pinfo->dbf = cdb;
-#if DBA_CDB_BUILTIN
-               php_stream_close(file);
-#else
-               close(file);
-#endif
-               *error = "Out of memory";
-               return FAILURE;
-       }
+       cdb = emalloc(sizeof(dba_cdb));
+       memset(cdb, 0, sizeof(dba_cdb));
 
 #if DBA_CDB_BUILTIN
        if (make) {
index eb6942f84a6beedd266643b574366548ad99d8bf..580e6f62e205d09f20b9134c7ccb24b271de6d28 100644 (file)
@@ -76,11 +76,8 @@ DBA_OPEN_FUNC(db2)
                return FAILURE;
        }
 
-       info->dbf = ecalloc(sizeof(dba_db2_data), 1);
-       if (!info->dbf) {
-               *error = "Out of memory";
-               return FAILURE;
-       }
+       info->dbf = emalloc(sizeof(dba_db2_data));
+       memset(info->dbf, 0, sizeof(dba_db2_data));
        ((dba_db2_data *) info->dbf)->dbp = dbp;
        return SUCCESS;
 }
index 5dd3af58f76ab8213a1fd823c88a14379fa495ea..df9396dedeb67848b3c13028eb33400c0ba56379 100644 (file)
@@ -78,10 +78,6 @@ DBA_OPEN_FUNC(db3)
                dba_db3_data *data;
 
                data = emalloc(sizeof(*data));
-               if (!data) {
-                       *error = "Out of memory";
-                       return FAILURE;
-               }
                data->dbp = dbp;
                data->cursor = NULL;
                info->dbf = data;
index 5763fad41eb5a576a80b9491f32c039b24efa7b0..4eca420786373a618aad2533fa3c72c7002fd740 100644 (file)
@@ -78,11 +78,8 @@ DBA_OPEN_FUNC(dbm)
                return FAILURE;
        }
 
-       info->dbf = ecalloc(sizeof(dba_dbm_data), 1);
-       if (!info->dbf) {
-               *error = "Out of memory";
-               return FAILURE;
-       }
+       info->dbf = emalloc(sizeof(dba_dbm_data));
+       memset(info->dbf, 0, sizeof(dba_dbm_data));
        return SUCCESS;
 }
 
index d64a7feec1a33a595e3c5d699ff819d6b602f57f..986b59cd19b0af20e0dd8e90f181efb3e9c5957e 100644 (file)
@@ -68,11 +68,8 @@ DBA_OPEN_FUNC(flatfile)
        int retries = 0;
 #endif
 
-       info->dbf = ecalloc(sizeof(flatfile), 1);
-       if (!info->dbf) {
-               *error = "Out of memory";
-               return FAILURE;
-       }
+       info->dbf = emalloc(sizeof(flatfile));
+       memset(info->dbf, 0, sizeof(flatfile));
 
        switch(info->mode) {
                case DBA_READER:
index 9343685d3bb0b70308106718ec46d420d97f7ad9..386c8f08745469240888ffce6ee061190e5d302f 100644 (file)
@@ -59,12 +59,8 @@ DBA_OPEN_FUNC(gdbm)
        dbf = gdbm_open(info->path, 0, gmode, filemode, NULL);
        
        if(dbf) {
-               info->dbf = ecalloc(sizeof(dba_gdbm_data), 1);
-               if (!info->dbf) {
-                       *error = "Out of memory";
-                       gdbm_close(dbf);
-                       return FAILURE;
-               }
+               info->dbf = emalloc(sizeof(dba_gdbm_data));
+               memset(info->dbf, 0, sizeof(dba_gdbm_data));
                ((dba_gdbm_data *) info->dbf)->dbf = dbf;
                return SUCCESS;
        }
index a362cfc2cc7acda7439bf1ed850710e2a147ccd5..06583c780bcb34ffe11b9dc5a05121904265b7d4 100644 (file)
@@ -65,12 +65,8 @@ DBA_OPEN_FUNC(ndbm)
 
        dbf = dbm_open(info->path, gmode, filemode);
        
-       if(dbf) {
-               pinfo->dbf = dbf;
-               return SUCCESS;
-       }
-       *error = "Out of memory";
-       return FAILURE;
+       pinfo->dbf = dbf;
+       return SUCCESS;
 }
 
 DBA_CLOSE_FUNC(ndbm)