Changes by: uvman
Update of /cvs/linux-ntfs/ntfsprogs/libntfs
In directory delta357:/tmp/cvs-serv5422/libntfs
Modified Files:
attrib.c bitmap.c compress.c device.c dir.c inode.c lcnalloc.c
logfile.c mft.c runlist.c security.c unistr.c unix_io.c
volume.c
Log Message:
Change callers of malloc() to ntfs_malloc() (Szaka). Fix compilition (Yuval).
Index: attrib.c
===================================================================
RCS file: /cvs/linux-ntfs/ntfsprogs/libntfs/attrib.c,v
retrieving revision 1.230
retrieving revision 1.231
diff -u -p -r1.230 -r1.231
--- attrib.c 28 Oct 2006 23:08:24 -0000 1.230
+++ attrib.c 1 Nov 2006 13:30:40 -0000 1.231
@@ -56,6 +56,7 @@
#include "compress.h"
#include "bitmap.h"
#include "logging.h"
+#include "support.h"
ntfschar AT_UNNAMED[] = { const_cpu_to_le16('\0') };
@@ -175,11 +176,10 @@ s64 ntfs_get_attribute_value(const ntfs_
* going to overflow in the same fashion.
* Temporary fix: same as above.
*/
- intbuf = malloc(rl[i].length << vol->cluster_size_bits);
+ intbuf = ntfs_malloc(rl[i].length <<
+ vol->cluster_size_bits);
if (!intbuf) {
int eo = errno;
- ntfs_log_perror("Couldn't allocate memory for "
- "internal buffer.");
free(rl);
errno = eo;
return 0;
@@ -1043,13 +1043,11 @@ s64 ntfs_attr_pwrite(ntfs_attr *na, cons
/* If write starts beyond initialized_size, zero the gap. */
if (pos > na->initialized_size) {
char *buf;
- int err;
- buf = malloc(NTFS_BUF_SIZE);
- if (!buf) {
- ntfs_log_trace("Not enough memory.\n");
+ buf = ntfs_malloc(NTFS_BUF_SIZE);
+ if (!buf)
goto err_out;
- }
+
memset(buf, 0, NTFS_BUF_SIZE);
ofs = na->initialized_size;
while (ofs < pos) {
@@ -1057,7 +1055,7 @@ s64 ntfs_attr_pwrite(ntfs_attr *na, cons
written = ntfs_rl_pwrite(vol, na->rl, ofs,
to_write, buf);
if (written <= 0) {
- err = errno;
+ int err = errno;
ntfs_log_trace("Failed to zero space "
"between initialized "
"size and @pos.\n");
@@ -2294,7 +2292,7 @@ ntfs_attr_search_ctx *ntfs_attr_get_sear
errno = EINVAL;
return NULL;
}
- ctx = malloc(sizeof(ntfs_attr_search_ctx));
+ ctx = ntfs_malloc(sizeof(ntfs_attr_search_ctx));
if (ctx)
ntfs_attr_init_search_ctx(ctx, ni, mrec);
return ctx;
@@ -4738,12 +4736,10 @@ static int ntfs_non_resident_attr_expand
* sparse runs instead of real allocation of clusters.
*/
if (na->type == AT_DATA && vol->major_ver >= 3) {
- rl = malloc(0x1000);
- if (!rl) {
- ntfs_log_trace("Not enough memory.\n");
- err = ENOMEM;
+ rl = ntfs_malloc(0x1000);
+ if (!rl)
return -1;
- }
+
rl[0].vcn = (na->allocated_size >>
vol->cluster_size_bits);
rl[0].lcn = LCN_HOLE;
@@ -4983,11 +4979,10 @@ void *ntfs_attr_readall(ntfs_inode *ni,
ntfs_log_perror("ntfs_attr_open failed");
return NULL;
}
- data = malloc(na->data_size);
- if (!data) {
- ntfs_log_perror("malloc failed");
+ data = ntfs_malloc(na->data_size);
+ if (!data)
goto out;
- }
+
size = ntfs_attr_pread(na, 0, na->data_size, data);
if (size != na->data_size) {
ntfs_log_perror("ntfs_attr_pread failed");
Index: bitmap.c
===================================================================
RCS file: /cvs/linux-ntfs/ntfsprogs/libntfs/bitmap.c,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -p -r1.25 -r1.26
--- bitmap.c 26 Oct 2006 19:10:05 -0000 1.25
+++ bitmap.c 1 Nov 2006 13:30:40 -0000 1.26
@@ -78,10 +78,10 @@ static int ntfs_bitmap_set_bits_in_run(n
if (bufsize > 8192)
bufsize = 8192;
- /* Allocate memory. */
- buf = (u8*)malloc(bufsize);
+ buf = (u8*)ntfs_malloc(bufsize);
if (!buf)
return -1;
+
/* Depending on @value, zero or set all bits in the allocated buffer. */
memset(buf, value ? 0xff : 0, bufsize);
Index: compress.c
===================================================================
RCS file: /cvs/linux-ntfs/ntfsprogs/libntfs/compress.c,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -p -r1.19 -r1.20
--- compress.c 29 Oct 2006 08:59:21 -0000 1.19
+++ compress.c 1 Nov 2006 13:30:40 -0000 1.20
@@ -375,12 +375,14 @@ s64 ntfs_compressed_attr_pread(ntfs_attr
cb_size = na->compression_block_size;
cb_size_mask = cb_size - 1UL;
cb_clusters = na->compression_block_clusters;
+
/* Need a temporary buffer for each loaded compression block. */
- cb = malloc(cb_size);
+ cb = ntfs_malloc(cb_size);
if (!cb)
return -1;
+
/* Need a temporary buffer for each uncompressed block. */
- dest = malloc(cb_size);
+ dest = ntfs_malloc(cb_size);
if (!dest) {
err = errno;
free(cb);
Index: device.c
===================================================================
RCS file: /cvs/linux-ntfs/ntfsprogs/libntfs/device.c,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -p -r1.30 -r1.31
--- device.c 26 Oct 2006 19:10:05 -0000 1.30
+++ device.c 1 Nov 2006 13:30:40 -0000 1.31
@@ -111,7 +111,7 @@ struct ntfs_device *ntfs_device_alloc(co
return NULL;
}
- dev = (struct ntfs_device *)malloc(sizeof(struct ntfs_device));
+ dev = (struct ntfs_device *)ntfs_malloc(sizeof(struct ntfs_device));
if (dev) {
if (!(dev->d_name = strdup(name))) {
int eo = errno;
Index: dir.c
===================================================================
RCS file: /cvs/linux-ntfs/ntfsprogs/libntfs/dir.c,v
retrieving revision 1.72
retrieving revision 1.73
diff -u -p -r1.72 -r1.73
--- dir.c 30 Oct 2006 13:43:09 -0000 1.72
+++ dir.c 1 Nov 2006 13:30:40 -0000 1.73
@@ -1270,12 +1270,9 @@ static ntfs_inode *__ntfs_create(ntfs_in
case S_IFBLK:
case S_IFCHR:
data_len = offsetof(INTX_FILE, device_end);
- data = malloc(data_len);
+ data = ntfs_malloc(data_len);
if (!data) {
err = errno;
- ntfs_log_error("Not enough memory for "
- "content of DATA "
- "attribute.\n");
goto err_out;
}
data->major = cpu_to_le64(major(dev));
@@ -1288,12 +1285,9 @@ static ntfs_inode *__ntfs_create(ntfs_in
case S_IFLNK:
data_len = sizeof(INTX_FILE_TYPES) +
target_len * sizeof(ntfschar);
- data = malloc(data_len);
+ data = ntfs_malloc(data_len);
if (!data) {
err = errno;
- ntfs_log_error("Not enough memory for "
- "content of DATA "
- "attribute.\n");
goto err_out;
}
data->magic = INTX_SYMBOLIC_LINK;
@@ -1322,10 +1316,9 @@ static ntfs_inode *__ntfs_create(ntfs_in
}
/* Create FILE_NAME attribute. */
fn_len = sizeof(FILE_NAME_ATTR) + name_len * sizeof(ntfschar);
- fn = calloc(1, fn_len);
+ fn = ntfs_calloc(fn_len);
if (!fn) {
err = errno;
- ntfs_log_error("Not enough memory.\n");
goto err_out;
}
fn->parent_directory = MK_LE_MREF(dir_ni->mft_no,
@@ -1711,16 +1704,15 @@ int ntfs_link(ntfs_inode *ni, ntfs_inode
if (!ni || !dir_ni || !name || !name_len ||
ni->mft_no == dir_ni->mft_no) {
- err = errno;
- ntfs_log_error("Invalid arguments.\n");
+ err = EINVAL;
+ ntfs_log_perror("ntfs_link wrong arguments");
goto err_out;
}
/* Create FILE_NAME attribute. */
fn_len = sizeof(FILE_NAME_ATTR) + name_len * sizeof(ntfschar);
- fn = calloc(1, fn_len);
+ fn = ntfs_calloc(fn_len);
if (!fn) {
err = errno;
- ntfs_log_error("Not enough memory.\n");
goto err_out;
}
fn->parent_directory = MK_LE_MREF(dir_ni->mft_no,
Index: inode.c
===================================================================
RCS file: /cvs/linux-ntfs/ntfsprogs/libntfs/inode.c,v
retrieving revision 1.87
retrieving revision 1.88
diff -u -p -r1.87 -r1.88
--- inode.c 27 Oct 2006 12:24:30 -0000 1.87
+++ inode.c 1 Nov 2006 13:30:40 -0000 1.88
@@ -180,7 +180,7 @@ ntfs_inode *ntfs_inode_open(ntfs_volume
goto put_err_out;
}
ni->attr_list_size = l;
- ni->attr_list = malloc(ni->attr_list_size);
+ ni->attr_list = ntfs_malloc(ni->attr_list_size);
if (!ni->attr_list)
goto put_err_out;
l = ntfs_get_attribute_value(vol, ctx->attr, ni->attr_list);
@@ -393,7 +393,7 @@ ntfs_inode *ntfs_extent_inode_open(ntfs_
if (!(base_ni->nr_extents & 3)) {
i = (base_ni->nr_extents + 4) * sizeof(ntfs_inode *);
- extent_nis = (ntfs_inode**)malloc(i);
+ extent_nis = (ntfs_inode**)ntfs_malloc(i);
if (!extent_nis)
goto err_out;
if (base_ni->nr_extents) {
Index: lcnalloc.c
===================================================================
RCS file: /cvs/linux-ntfs/ntfsprogs/libntfs/lcnalloc.c,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -p -r1.35 -r1.36
--- lcnalloc.c 10 Feb 2006 11:00:47 -0000 1.35
+++ lcnalloc.c 1 Nov 2006 13:30:40 -0000 1.36
@@ -122,7 +122,7 @@ runlist *ntfs_cluster_alloc(ntfs_volume
/* Return empty runlist if @count == 0 */
if (!count) {
- rl = malloc(0x1000);
+ rl = ntfs_malloc(0x1000);
if (!rl)
return NULL;
rl[0].vcn = start_vcn;
@@ -132,7 +132,7 @@ runlist *ntfs_cluster_alloc(ntfs_volume
}
/* Allocate memory. */
- buf = (u8*)malloc(8192);
+ buf = (u8*)ntfs_malloc(8192);
if (!buf)
return NULL;
/*
Index: logfile.c
===================================================================
RCS file: /cvs/linux-ntfs/ntfsprogs/libntfs/logfile.c,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -p -r1.17 -r1.18
--- logfile.c 21 Jul 2006 23:16:09 -0000 1.17
+++ logfile.c 1 Nov 2006 13:30:40 -0000 1.18
@@ -371,12 +371,9 @@ static int ntfs_check_and_load_restart_p
* Allocate a buffer to store the whole restart page so we can multi
* sector transfer deprotect it.
*/
- trp = malloc(le32_to_cpu(rp->system_page_size));
- if (!trp) {
- ntfs_log_error("Failed to allocate memory for $LogFile "
- "restart page buffer.\n");
+ trp = ntfs_malloc(le32_to_cpu(rp->system_page_size));
+ if (!trp)
return ENOMEM;
- }
/*
* Read the whole of the restart page into the buffer. If it fits
* completely inside @rp, just copy it from there. Otherwise read it
@@ -500,11 +497,9 @@ BOOL ntfs_check_logfile(ntfs_attr *log_n
return FALSE;
}
/* Allocate memory for restart page. */
- kaddr = malloc(NTFS_BLOCK_SIZE);
- if (!kaddr) {
- ntfs_log_error("Not enough memory.\n");
+ kaddr = ntfs_malloc(NTFS_BLOCK_SIZE);
+ if (!kaddr)
return FALSE;
- }
/*
* Read through the file looking for a restart page. Since the restart
* page header is at the beginning of a page we only need to search at
Index: mft.c
===================================================================
RCS file: /cvs/linux-ntfs/ntfsprogs/libntfs/mft.c,v
retrieving revision 1.47
retrieving revision 1.48
diff -u -p -r1.47 -r1.48
--- mft.c 21 Jul 2006 23:03:59 -0000 1.47
+++ mft.c 1 Nov 2006 13:30:40 -0000 1.48
@@ -158,7 +158,7 @@ int ntfs_mft_records_write(const ntfs_vo
cnt = vol->mftmirr_size - m;
if (cnt > count)
cnt = count;
- bmirr = malloc(cnt * vol->mft_record_size);
+ bmirr = ntfs_malloc(cnt * vol->mft_record_size);
if (!bmirr)
return -1;
memcpy(bmirr, b, cnt * vol->mft_record_size);
@@ -240,7 +240,7 @@ int ntfs_file_record_read(const ntfs_vol
}
m = *mrec;
if (!m) {
- m = (MFT_RECORD*)malloc(vol->mft_record_size);
+ m = (MFT_RECORD*)ntfs_malloc(vol->mft_record_size);
if (!m)
return -1;
}
@@ -367,7 +367,7 @@ int ntfs_mft_record_format(const ntfs_vo
errno = EINVAL;
return -1;
}
- m = malloc(vol->mft_record_size);
+ m = ntfs_calloc(vol->mft_record_size);
if (!m)
return -1;
if (ntfs_mft_record_layout(vol, mref, m)) {
@@ -459,9 +459,10 @@ static int ntfs_mft_bitmap_find_free_rec
}
}
pass_start = data_pos;
- buf = (u8*)malloc(PAGE_SIZE);
+ buf = (u8*)ntfs_malloc(PAGE_SIZE);
if (!buf)
return -1;
+
ntfs_log_debug("Starting bitmap search: pass %u, pass_start 0x%llx, "
"pass_end 0x%llx, data_pos 0x%llx.\n", pass,
(long long)pass_start, (long long)pass_end,
@@ -1368,12 +1369,10 @@ mft_rec_already_initialized:
* is not zero as well as the update sequence number if it is not zero
* or -1 (0xffff).
*/
- m = (MFT_RECORD*)malloc(vol->mft_record_size);
- if (!m) {
- ntfs_log_error("Failed to allocate buffer for mft "
- "record.\n");
+ m = (MFT_RECORD*)ntfs_malloc(vol->mft_record_size);
+ if (!m)
goto undo_mftbmp_alloc;
- }
+
if (ntfs_mft_record_read(vol, bit, m)) {
err = errno;
ntfs_log_error("Failed to read mft record.\n");
@@ -1437,12 +1436,9 @@ mft_rec_already_initialized:
int i;
i = (base_ni->nr_extents + 4) * sizeof(ntfs_inode *);
- extent_nis = (ntfs_inode**)malloc(i);
+ extent_nis = (ntfs_inode**)ntfs_malloc(i);
if (!extent_nis) {
err = errno;
- ntfs_log_error("Failed to allocate "
- "buffer for extent inodes "
- "array.\n");
free(m);
free(ni);
errno = err;
Index: runlist.c
===================================================================
RCS file: /cvs/linux-ntfs/ntfsprogs/libntfs/runlist.c,v
retrieving revision 1.73
retrieving revision 1.74
diff -u -p -r1.73 -r1.74
--- runlist.c 27 Oct 2006 12:24:30 -0000 1.73
+++ runlist.c 1 Nov 2006 13:30:40 -0000 1.74
@@ -766,7 +766,8 @@ runlist_element *ntfs_mapping_pairs_deco
/* Current position in runlist array. */
rlpos = 0;
/* Allocate first 4kiB block and set current runlist size to 4kiB. */
- rl = malloc(rlsize = 0x1000);
+ rlsize = 0x1000;
+ rl = ntfs_malloc(rlsize);
if (!rl)
return NULL;
/* Insert unmapped starting element if necessary. */
@@ -1824,7 +1825,10 @@ static runlist_element * test_rl_pure_sr
else
fudge = 999;
- result = malloc(4096);
+ result = ntfs_malloc(4096);
+ if (!result)
+ return NULL;
+
if (multi) {
MKRL(result+0, vcn + (0*len/4), fudge + vcn + 1000 + (0*len/4), len / 4)
MKRL(result+1, vcn + (1*len/4), fudge + vcn + 1000 + (1*len/4), len / 4)
@@ -2042,9 +2046,9 @@ static void test_rl_frag_combine(ntfs_vo
static void test_rl_frag(char *test)
{
ntfs_volume vol;
- ATTR_RECORD *attr1 = malloc(1024);
- ATTR_RECORD *attr2 = malloc(1024);
- ATTR_RECORD *attr3 = malloc(1024);
+ ATTR_RECORD *attr1 = ntfs_malloc(1024);
+ ATTR_RECORD *attr2 = ntfs_malloc(1024);
+ ATTR_RECORD *attr3 = ntfs_malloc(1024);
if (!attr1 || !attr2 || !attr3)
goto out;
Index: security.c
===================================================================
RCS file: /cvs/linux-ntfs/ntfsprogs/libntfs/security.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -p -r1.18 -r1.19
--- security.c 20 Oct 2006 19:53:50 -0000 1.18
+++ security.c 1 Nov 2006 13:30:40 -0000 1.19
@@ -85,7 +85,7 @@ char *ntfs_guid_to_mbs(const GUID *guid,
}
_guid_str = guid_str;
if (!_guid_str) {
- _guid_str = malloc(37);
+ _guid_str = ntfs_malloc(37);
if (!_guid_str)
return _guid_str;
}
@@ -201,7 +201,7 @@ char *ntfs_sid_to_mbs(const SID *sid, ch
cnt = ntfs_sid_to_mbs_size(sid);
if (cnt < 0)
return NULL;
- s = malloc(cnt);
+ s = ntfs_malloc(cnt);
if (!s)
return s;
sid_str = s;
Index: unistr.c
===================================================================
RCS file: /cvs/linux-ntfs/ntfsprogs/libntfs/unistr.c,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -p -r1.36 -r1.37
--- unistr.c 27 Oct 2006 12:24:30 -0000 1.36
+++ unistr.c 1 Nov 2006 13:30:40 -0000 1.37
@@ -299,7 +299,7 @@ ntfschar *ntfs_ucsndup(const ntfschar *s
u32 len;
len = ntfs_ucsnlen(s, maxlen);
- dst = malloc((len + 1) * sizeof(ntfschar));
+ dst = ntfs_malloc((len + 1) * sizeof(ntfschar));
if (dst) {
memcpy(dst, s, len * sizeof(ntfschar));
dst[len] = cpu_to_le16(L'\0');
@@ -419,7 +419,7 @@ int ntfs_ucstombs(const ntfschar *ins, c
}
if (!mbs) {
mbs_len = (ins_len + 1) * MB_CUR_MAX;
- mbs = (char*)malloc(mbs_len);
+ mbs = (char*)ntfs_malloc(mbs_len);
if (!mbs)
return -1;
}
@@ -436,7 +436,7 @@ int ntfs_ucstombs(const ntfschar *ins, c
errno = ENAMETOOLONG;
return -1;
}
- tc = (char*)malloc((mbs_len + 64) & ~63);
+ tc = (char*)ntfs_malloc((mbs_len + 64) & ~63);
if (!tc)
goto err_out;
memcpy(tc, mbs, mbs_len);
@@ -562,7 +562,7 @@ int ntfs_mbstoucs(const char *ins, ntfsc
ins_len++;
if (!ucs) {
ucs_len = ins_len;
- ucs = (ntfschar*)malloc(ucs_len * sizeof(ntfschar));
+ ucs = (ntfschar*)ntfs_malloc(ucs_len * sizeof(ntfschar));
if (!ucs)
return -1;
}
Index: unix_io.c
===================================================================
RCS file: /cvs/linux-ntfs/ntfsprogs/libntfs/unix_io.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -p -r1.13 -r1.14
--- unix_io.c 27 Oct 2006 12:24:30 -0000 1.13
+++ unix_io.c 1 Nov 2006 13:30:40 -0000 1.14
@@ -86,7 +86,7 @@ static int ntfs_device_unix_io_open(stru
errno = EBUSY;
return -1;
}
- if (!(dev->d_private = malloc(sizeof(int))))
+ if (!(dev->d_private = ntfs_malloc(sizeof(int))))
return -1;
/*
* Open the device/file obtaining the file descriptor for exclusive
Index: volume.c
===================================================================
RCS file: /cvs/linux-ntfs/ntfsprogs/libntfs/volume.c,v
retrieving revision 1.73
retrieving revision 1.74
diff -u -p -r1.73 -r1.74
--- volume.c 27 Oct 2006 14:15:32 -0000 1.73
+++ volume.c 1 Nov 2006 13:30:40 -0000 1.74
@@ -147,7 +147,7 @@ static int ntfs_mft_load(ntfs_volume *vo
/* Manually setup an ntfs_inode. */
vol->mft_ni = ntfs_inode_allocate(vol);
- mb = (MFT_RECORD*)malloc(vol->mft_record_size);
+ mb = (MFT_RECORD*)ntfs_malloc(vol->mft_record_size);
if (!vol->mft_ni || !mb) {
ntfs_log_perror("Error allocating memory for $MFT");
goto error_exit;
@@ -198,12 +198,10 @@ static int ntfs_mft_load(ntfs_volume *vo
goto io_error_exit;
}
vol->mft_ni->attr_list_size = l;
- vol->mft_ni->attr_list = malloc(l);
- if (!vol->mft_ni->attr_list) {
- ntfs_log_debug("Error: failed to allocate buffer for attribute "
- "list.\n");
+ vol->mft_ni->attr_list = ntfs_malloc(l);
+ if (!vol->mft_ni->attr_list)
goto error_exit;
- }
+
l = ntfs_get_attribute_value(vol, ctx->attr, vol->mft_ni->attr_list);
if (!l) {
ntfs_log_debug("Error: failed to get value of "
@@ -421,20 +419,20 @@ ntfs_volume *ntfs_volume_startup(struct
return NULL;
}
- /* Allocate the boot sector structure. */
- if (!(bs = (NTFS_BOOT_SECTOR *)malloc(sizeof(NTFS_BOOT_SECTOR))))
+ if (!(bs = (NTFS_BOOT_SECTOR *)ntfs_malloc(sizeof(NTFS_BOOT_SECTOR))))
return NULL;
+
/* Allocate the volume structure. */
vol = ntfs_volume_alloc();
if (!vol)
goto error_exit;
/* Create the default upcase table. */
vol->upcase_len = 65536;
- vol->upcase = (ntfschar*)malloc(vol->upcase_len * sizeof(ntfschar));
- if (!vol->upcase) {
- ntfs_log_perror("Error allocating memory for upcase table.");
+ vol->upcase = (ntfschar*)ntfs_malloc(vol->upcase_len *
+ sizeof(ntfschar));
+ if (!vol->upcase)
goto error_exit;
- }
+
ntfs_upcase_table_build(vol->upcase,
vol->upcase_len * sizeof(ntfschar));
if (flags & MS_RDONLY)
@@ -697,11 +695,9 @@ static int ntfs_volume_check_hiberfile(n
return -1;
}
- buf = malloc(NTFS_HIBERFILE_HEADER_SIZE);
- if (!buf) {
- ntfs_log_perror("Error allocating memory for hiberfile.sys header");
+ buf = ntfs_malloc(NTFS_HIBERFILE_HEADER_SIZE);
+ if (!buf)
goto out;
- }
na = ntfs_attr_open(ni, AT_DATA, AT_UNNAMED, 0);
if (!na) {
@@ -790,12 +786,10 @@ ntfs_volume *ntfs_device_mount(struct nt
}
/* Load data from $MFT and $MFTMirr and compare the contents. */
- m = (u8*)malloc(vol->mftmirr_size << vol->mft_record_size_bits);
- m2 = (u8*)malloc(vol->mftmirr_size << vol->mft_record_size_bits);
- if (!m || !m2) {
- ntfs_log_perror("Failed to allocate memory");
+ m = (u8*)ntfs_malloc(vol->mftmirr_size << vol->mft_record_size_bits);
+ m2 = (u8*)ntfs_malloc(vol->mftmirr_size << vol->mft_record_size_bits);
+ if (!m || !m2)
goto error_exit;
- }
l = ntfs_attr_mst_pread(vol->mft_na, 0, vol->mftmirr_size,
vol->mft_record_size, m);
@@ -932,10 +926,9 @@ ntfs_volume *ntfs_device_mount(struct nt
vol->upcase_len = na->data_size >> 1;
/* Throw away default table. */
free(vol->upcase);
- vol->upcase = (ntfschar*)malloc(na->data_size);
+ vol->upcase = (ntfschar*)ntfs_malloc(na->data_size);
if (!vol->upcase) {
ntfs_log_debug(FAILED);
- ntfs_log_debug("Not enough memory to load $UpCase.\n");
goto error_exit;
}
}
@@ -1026,11 +1019,9 @@ ntfs_volume *ntfs_device_mount(struct nt
* Treat this the same way as if the attribute was present but
* had zero length.
*/
- vol->vol_name = malloc(1);
+ vol->vol_name = ntfs_malloc(1);
if (!vol->vol_name) {
ntfs_log_debug(FAILED);
- ntfs_log_debug("Error: Unable to allocate memory for volume "
- "name!\n");
goto error_exit;
}
vol->vol_name[0] = '\0';
@@ -1057,11 +1048,9 @@ ntfs_volume *ntfs_device_mount(struct nt
"to current locale");
ntfs_log_debug("Forcing name into ASCII by replacing "
"non-ASCII characters with underscores.\n");
- vol->vol_name = malloc(u + 1);
+ vol->vol_name = ntfs_malloc(u + 1);
if (!vol->vol_name) {
ntfs_log_debug(FAILED);
- ntfs_log_debug("Error: Unable to allocate memory for "
- "volume name!\n");
goto error_exit;
}
for (j = 0; j < (s32)u; j++) {
@@ -1100,10 +1089,9 @@ ntfs_volume *ntfs_device_mount(struct nt
goto error_exit;
}
vol->attrdef_len = na->data_size;
- vol->attrdef = (ATTR_DEF*)malloc(na->data_size);
+ vol->attrdef = (ATTR_DEF*)ntfs_malloc(na->data_size);
if (!vol->attrdef) {
ntfs_log_debug(FAILED);
- ntfs_log_debug("Not enough memory to load $AttrDef.\n");
goto error_exit;
}
/* Read in the $DATA attribute value into the buffer. */
@@ -1303,10 +1291,10 @@ static int ntfs_mntent_check(const char
FILE *f;
int err = 0;
- real_file = malloc(PATH_MAX + 1);
+ real_file = ntfs_malloc(PATH_MAX + 1);
if (!real_file)
return -1;
- real_fsname = malloc(PATH_MAX + 1);
+ real_fsname = ntfs_malloc(PATH_MAX + 1);
if (!real_fsname) {
err = errno;
goto exit;
|