DWORD status;
DEBUG_DVC("in");
rbytes_per_frame = alsa->actual_channels * alsa->bytes_per_channel;
- buffer = (BYTE*) calloc(1, rbytes_per_frame * alsa->frames_per_packet);
+ buffer = (BYTE*) calloc(alsa->frames_per_packet, rbytes_per_frame);
if (!buffer)
{
alsa->receive = receive;
alsa->user_data = user_data;
tbytes_per_frame = alsa->target_channels * alsa->bytes_per_channel;
- alsa->buffer = (BYTE*) calloc(1, tbytes_per_frame * alsa->frames_per_packet);
+ alsa->buffer = (BYTE*) calloc(alsa->frames_per_packet, tbytes_per_frame);
if (!alsa->buffer)
{
}
Stream_Seek_UINT32(s); /* cbSizeFormatsPacket */
- callback->formats = (audinFormat*) calloc(1, NumFormats * sizeof(audinFormat));
+ callback->formats = (audinFormat*) calloc(NumFormats, sizeof(audinFormat));
if (!callback->formats)
{
int bufferframes, int bits_per_sample)
{
OPENSL_STREAM* p;
- p = (OPENSL_STREAM*) calloc(sizeof(OPENSL_STREAM), 1);
+ p = (OPENSL_STREAM*) calloc(1, sizeof(OPENSL_STREAM));
if (!p)
return NULL;
pa_threaded_mainloop_unlock(pulse->mainloop);
freerdp_dsp_context_reset_adpcm(pulse->dsp_context);
- pulse->buffer = calloc(1, pulse->bytes_per_frame * pulse->frames_per_packet);
+ pulse->buffer = calloc(pulse->frames_per_packet, pulse->bytes_per_frame);
if (!pulse->buffer)
{
FREERDP_ADDIN** ppAddins = NULL;
STATIC_SUBSYSTEM_ENTRY* subsystems;
nAddins = 0;
- ppAddins = (FREERDP_ADDIN**) calloc(1, sizeof(FREERDP_ADDIN*) * 128);
+ ppAddins = (FREERDP_ADDIN**) calloc(128, sizeof(FREERDP_ADDIN*));
if (!ppAddins)
{
hFind = FindFirstFileA(pszSearchPath, &FindData);
free(pszSearchPath);
nAddins = 0;
- ppAddins = (FREERDP_ADDIN**) calloc(1, sizeof(FREERDP_ADDIN*) * 128);
+ ppAddins = (FREERDP_ADDIN**) calloc(128, sizeof(FREERDP_ADDIN*));
if (!ppAddins)
{
int i;
num_dests = cupsGetDests(&dests);
- printers = (rdpPrinter**) calloc(1, sizeof(rdpPrinter*) * (num_dests + 1));
+ printers = (rdpPrinter**) calloc(num_dests + 1, sizeof(rdpPrinter*));
if (!printers)
return NULL;
goto error_out;
}
- meta->regionRects = (RECTANGLE_16*) malloc(meta->numRegionRects * sizeof(RECTANGLE_16));
+ meta->regionRects = (RECTANGLE_16*) calloc(meta->numRegionRects, sizeof(RECTANGLE_16));
if (!meta->regionRects)
{
goto error_out;
}
- meta->quantQualityVals = (RDPGFX_H264_QUANT_QUALITY*) malloc(meta->numRegionRects * sizeof(
+ meta->quantQualityVals = (RDPGFX_H264_QUANT_QUALITY*) calloc(meta->numRegionRects, sizeof(
RDPGFX_H264_QUANT_QUALITY));
if (!meta->quantQualityVals)
return CHANNEL_RC_OK;
}
- pSurfaceIds = (UINT16*) malloc(count * sizeof(UINT16));
+ pSurfaceIds = (UINT16*) calloc(count, sizeof(UINT16));
if (!pSurfaceIds)
{
int bufferframes)
{
OPENSL_STREAM* p;
- p = (OPENSL_STREAM*) calloc(sizeof(OPENSL_STREAM), 1);
+ p = (OPENSL_STREAM*) calloc(1, sizeof(OPENSL_STREAM));
if (!p)
return NULL;
if (!rdpsnd->NumberOfServerFormats)
return;
- rdpsnd->ClientFormats = (AUDIO_FORMAT*) calloc(sizeof(AUDIO_FORMAT),
- rdpsnd->NumberOfServerFormats);
+ rdpsnd->ClientFormats = (AUDIO_FORMAT*) calloc(
+ rdpsnd->NumberOfServerFormats,
+ sizeof(AUDIO_FORMAT));
if (!rdpsnd->ClientFormats)
return;
Stream_Seek_UINT32(s); /* NdrMaxCount (4 bytes) */
Stream_Seek_UINT32(s); /* NdrOffset (4 bytes) */
Stream_Read_UINT32(s, count); /* NdrActualCount (4 bytes) */
- call->szReader = (WCHAR*) malloc((count + 1) * 2);
+ call->szReader = (WCHAR*) calloc((count + 1), 2);
if (!call->szReader)
{
return STATUS_BUFFER_TOO_SMALL;
}
- readerState->szReader = (WCHAR*) malloc((count + 1) * 2);
+ readerState->szReader = (WCHAR*) calloc((count + 1), 2);
if (!readerState->szReader)
{
if (presentation->nr_rects > 0)
{
event.numVisibleRects = presentation->nr_rects;
- event.visibleRects = (RECTANGLE_16*) calloc(1, event.numVisibleRects * sizeof(RECTANGLE_16));
+ event.visibleRects = (RECTANGLE_16*) calloc(event.numVisibleRects, sizeof(RECTANGLE_16));
if (!event.visibleRects)
{
LibusbInterface = &LibusbConfig->interface[MsInterface->InterfaceNumber];
LibusbAltsetting = &LibusbInterface->altsetting[MsInterface->AlternateSetting];
LibusbNumEndpoint = LibusbAltsetting->bNumEndpoints;
- t_MsPipes = (MSUSB_PIPE_DESCRIPTOR**) malloc(LibusbNumEndpoint * sizeof(MSUSB_PIPE_DESCRIPTOR*));
+ t_MsPipes = (MSUSB_PIPE_DESCRIPTOR**) calloc(LibusbNumEndpoint, sizeof(MSUSB_PIPE_DESCRIPTOR*));
for (pnum = 0; pnum < LibusbNumEndpoint; pnum++)
{
return FALSE;
}
- queue->events = (ANDROID_EVENT**) calloc(sizeof(ANDROID_EVENT*), queue->size);
+ queue->events = (ANDROID_EVENT**) calloc(queue->size, sizeof(ANDROID_EVENT*));
if (!queue->events)
{
&& clipboard->GetUpdatedClipboardFormats))
clipboard->legacyApi = TRUE;
- if (!(clipboard->format_mappings = (formatMapping*) calloc(1,
- sizeof(formatMapping) * clipboard->map_capacity)))
+ if (!(clipboard->format_mappings = (formatMapping*) calloc(clipboard->map_capacity,
+ sizeof(formatMapping))))
goto error;
if (!(clipboard->response_data_event = CreateEvent(NULL, TRUE, FALSE,
XSetFillStyle(xfc->display, xfc->gc, FillSolid);
XSetForeground(xfc->display, xfc->gc, color.pixel);
npoints = polyline->numDeltaEntries + 1;
- points = malloc(sizeof(XPoint) * npoints);
+ points = calloc(npoints, sizeof(XPoint));
if (!points)
{
xf_lock_x11(xfc, FALSE);
xf_set_rop2(xfc, polygon_sc->bRop2);
npoints = polygon_sc->numPoints + 1;
- points = malloc(sizeof(XPoint) * npoints);
+ points = calloc(npoints, sizeof(XPoint));
if (!points)
{
brush = &(polygon_cb->brush);
xf_set_rop2(xfc, polygon_cb->bRop2);
npoints = polygon_cb->numPoints + 1;
- points = malloc(sizeof(XPoint) * npoints);
+ points = calloc(npoints, sizeof(XPoint));
if (!points)
{
return FALSE;
}
- buffer = (char*) malloc((length + 1) * sizeof(char));
+ buffer = (char*) calloc((length + 1), sizeof(char));
if (freerdp_client_write_rdp_file_buffer(file, buffer, length + 1) != length)
{
FillMemory(file, sizeof(rdpFile), 0xFF);
file->lineCount = 0;
file->lineSize = 32;
- file->lines = (rdpFileLine*) malloc(file->lineSize * sizeof(rdpFileLine));
+ file->lines = (rdpFileLine*) calloc(file->lineSize, sizeof(rdpFileLine));
if (!file->lines)
{
file->argc = 0;
file->argSize = 32;
- file->argv = (char**) malloc(file->argSize * sizeof(char*));
+ file->argv = (char**) calloc(file->argSize, sizeof(char*));
if (!file->argv)
{
if (width * height == 0)
return NULL;
- if (!(outPlane = (BYTE*) malloc(width * height)))
+ if (!(outPlane = (BYTE*) calloc(height, width)))
return NULL;
}
free(context->pTempData);
free(context->deltaPlanesBuffer);
free(context->rlePlanesBuffer);
- context->planesBuffer = malloc(context->maxPlaneSize * 4);
- context->pTempData = malloc(context->maxPlaneSize * 4);
- context->deltaPlanesBuffer = malloc(context->maxPlaneSize * 4);
- context->rlePlanesBuffer = malloc(context->maxPlaneSize * 4);
+ context->planesBuffer = calloc(context->maxPlaneSize, 4);
+ context->pTempData = calloc(context->maxPlaneSize, 4);
+ context->deltaPlanesBuffer = calloc(context->maxPlaneSize, 4);
+ context->rlePlanesBuffer = calloc(context->maxPlaneSize, 4);
if (!context->planesBuffer || !context->pTempData ||
!context->deltaPlanesBuffer || !context->rlePlanesBuffer)
progressive->Compressor = Compressor;
progressive->bufferPool = BufferPool_New(TRUE, (8192 + 32) * 3, 16);
progressive->cRects = 64;
- progressive->rects = (RFX_RECT*) malloc(progressive->cRects * sizeof(RFX_RECT));
+ progressive->rects = (RFX_RECT*) calloc(progressive->cRects, sizeof(RFX_RECT));
if (!progressive->rects)
goto cleanup;
progressive->cTiles = 64;
- progressive->tiles = (RFX_PROGRESSIVE_TILE**) malloc(progressive->cTiles *
+ progressive->tiles = (RFX_PROGRESSIVE_TILE**) calloc(progressive->cTiles,
sizeof(RFX_PROGRESSIVE_TILE*));
if (!progressive->tiles)
goto cleanup;
progressive->cQuant = 8;
- progressive->quantVals = (RFX_COMPONENT_CODEC_QUANT*) malloc(
- progressive->cQuant * sizeof(RFX_COMPONENT_CODEC_QUANT));
+ progressive->quantVals = (RFX_COMPONENT_CODEC_QUANT*) calloc(
+ progressive->cQuant, sizeof(RFX_COMPONENT_CODEC_QUANT));
if (!progressive->quantVals)
goto cleanup;
progressive->cProgQuant = 8;
- progressive->quantProgVals = (RFX_PROGRESSIVE_CODEC_QUANT*) malloc(
- progressive->cProgQuant * sizeof(RFX_PROGRESSIVE_CODEC_QUANT));
+ progressive->quantProgVals = (RFX_PROGRESSIVE_CODEC_QUANT*) calloc(
+ progressive->cProgQuant, sizeof(RFX_PROGRESSIVE_CODEC_QUANT));
if (!progressive->quantProgVals)
goto cleanup;
UINT32 dstSize;
BYTE* compressedBitmap = freerdp_bitmap_compress_planar(planar,
srcBitmap, srcFormat, width, height, 0, NULL, &dstSize);
- BYTE* decompressedBitmap = (BYTE*) calloc(1, size);
+ BYTE* decompressedBitmap = (BYTE*) calloc(height, width * GetBytesPerPixel(dstFormat));
printf("%s [%s] --> [%s]: ", __FUNCTION__,
GetColorFormatName(srcFormat), GetColorFormatName(dstFormat));
fflush(stdout);
pad2[i] ^= hash[i];
}
- buffer = (BYTE*) calloc(1, hashLength * 2);
+ buffer = (BYTE*) calloc(hashLength, 2);
if (!buffer)
goto fail;
count++;
}
- tokens = (char**) malloc(sizeof(char*) * count);
+ tokens = (char**) calloc(count, sizeof(char*));
if (!tokens)
{
free(str);
int ln, hn;
char bin2hex[] = "0123456789ABCDEF";
- p = (char*) malloc((size + 1) * 2);
+ p = (char*) calloc((size + 1), 2);
if (!p)
return NULL;
return NULL;
_channel->argc = channel->argc;
- _channel->argv = (char**) malloc(sizeof(char*) * channel->argc);
+ _channel->argv = (char**) calloc(sizeof(char*), channel->argc);
if (!_channel->argv)
goto out_free;
* client random must be (bitlen / 8) + 8 - see [MS-RDPBCGR] 5.3.4.1
* for details
*/
- crypt_client_random = calloc(1, key_len + 8);
+ crypt_client_random = calloc(key_len + 8, 1);
if (!crypt_client_random)
return FALSE;
if (DsMakeSpn(ServiceClass, hostnameX, NULL, 0, NULL, &SpnLength, NULL) != ERROR_BUFFER_OVERFLOW)
goto error;
- ntlm->ServicePrincipalName = (LPTSTR) malloc(SpnLength * sizeof(TCHAR));
+ ntlm->ServicePrincipalName = (LPTSTR) calloc(SpnLength, sizeof(TCHAR));
if (!ntlm->ServicePrincipalName)
goto error;
return FALSE;
scopeList->count = scopeCount;
- scopeList->array = (LICENSE_BLOB*) malloc(sizeof(LICENSE_BLOB) * scopeCount);
+ scopeList->array = (LICENSE_BLOB*) calloc(scopeCount, sizeof(LICENSE_BLOB));
if (!scopeList->array)
return FALSE;
wParam->number = bitmap->number;
wParam->count = wParam->number;
- wParam->rectangles = (BITMAP_DATA*) malloc(sizeof(BITMAP_DATA) * wParam->number);
+ wParam->rectangles = (BITMAP_DATA*) calloc(wParam->number, sizeof(BITMAP_DATA));
if (!wParam->rectangles)
{
if (!context || !context->update || !areas)
return FALSE;
- lParam = (RECTANGLE_16*) malloc(sizeof(RECTANGLE_16) * count);
+ lParam = (RECTANGLE_16*) calloc(count, sizeof(RECTANGLE_16));
if (!lParam)
return FALSE;
return FALSE;
CopyMemory(wParam, polyline, sizeof(POLYLINE_ORDER));
- wParam->points = (DELTA_POINT*) malloc(sizeof(DELTA_POINT) * wParam->numDeltaEntries);
+ wParam->points = (DELTA_POINT*) calloc(wParam->numDeltaEntries, sizeof(DELTA_POINT));
if (!wParam->points)
{
return FALSE;
CopyMemory(wParam, polygonSC, sizeof(POLYGON_SC_ORDER));
- wParam->points = (DELTA_POINT*) malloc(sizeof(DELTA_POINT) * wParam->numPoints);
+ wParam->points = (DELTA_POINT*) calloc(wParam->numPoints, sizeof(DELTA_POINT));
if (!wParam->points)
{
return FALSE;
CopyMemory(wParam, polygonCB, sizeof(POLYGON_CB_ORDER));
- wParam->points = (DELTA_POINT*) malloc(sizeof(DELTA_POINT) * wParam->numPoints);
+ wParam->points = (DELTA_POINT*) calloc(wParam->numPoints, sizeof(DELTA_POINT));
if (!wParam->points)
{
CopyMemory(wParam, createOffscreenBitmap, sizeof(CREATE_OFFSCREEN_BITMAP_ORDER));
wParam->deleteList.cIndices = createOffscreenBitmap->deleteList.cIndices;
wParam->deleteList.sIndices = wParam->deleteList.cIndices;
- wParam->deleteList.indices = (UINT16*) malloc(sizeof(UINT16) * wParam->deleteList.cIndices);
+ wParam->deleteList.indices = (UINT16*) calloc(wParam->deleteList.cIndices, sizeof(UINT16));
if (!wParam->deleteList.indices)
{
if (lParam->numWindowIds)
{
- lParam->windowIds = (UINT32*) malloc(sizeof(UINT32) * lParam->numWindowIds);
+ lParam->windowIds = (UINT32*) calloc(lParam->numWindowIds, sizeof(UINT32));
CopyMemory(lParam->windowIds, monitoredDesktop->windowIds, lParam->numWindowIds);
}
return NULL;
}
- ServicePrincipalName = (LPTSTR) malloc(SpnLength * sizeof(TCHAR));
+ ServicePrincipalName = (LPTSTR) calloc(SpnLength, sizeof(TCHAR));
if (!ServicePrincipalName)
{
hostnamelen = strlen(hostname);
}
- settings->ProxyHostname = calloc(1, hostnamelen + 1);
+ settings->ProxyHostname = calloc(hostnamelen + 1, 1);
if (!settings->ProxyHostname)
{
UINT32 i;
freerdp_target_net_addresses_free(settings);
settings->TargetNetAddressCount = redirection->TargetNetAddressesCount;
- settings->TargetNetAddresses = (char**) malloc(sizeof(char*) * settings->TargetNetAddressCount);
+ settings->TargetNetAddresses = (char**) calloc(settings->TargetNetAddressCount, sizeof(char*));
if (!settings->TargetNetAddresses)
{
settings->TargetNetAddressCount = 0;
if (_settings->ChannelDefArraySize > 0)
{
- _settings->ChannelDefArray = (CHANNEL_DEF*) malloc(sizeof(
- CHANNEL_DEF) * settings->ChannelDefArraySize);
+ _settings->ChannelDefArray = (CHANNEL_DEF*) calloc(settings->ChannelDefArraySize,
+ sizeof(CHANNEL_DEF));
if (!_settings->ChannelDefArray)
goto out_fail;
if (_settings->MonitorDefArraySize > 0)
{
- _settings->MonitorDefArray = (rdpMonitor*) malloc(sizeof(
- rdpMonitor) * settings->MonitorDefArraySize);
+ _settings->MonitorDefArray = (rdpMonitor*) calloc(settings->MonitorDefArraySize,
+ sizeof(rdpMonitor));
if (!_settings->MonitorDefArray)
goto out_fail;
if (Stream_GetRemainingLength(s) < ((size_t) numberOfAreas * 4 * 2))
return FALSE;
- areas = (RECTANGLE_16*) malloc(sizeof(RECTANGLE_16) * numberOfAreas);
+ areas = (RECTANGLE_16*) calloc(numberOfAreas, sizeof(RECTANGLE_16));
if (!areas)
return FALSE;
deleteList = &(update->altsec->create_offscreen_bitmap.deleteList);
deleteList->sIndices = 64;
- deleteList->indices = malloc(deleteList->sIndices * 2);
+ deleteList->indices = calloc(deleteList->sIndices, 2);
if (!deleteList->indices)
goto error_indices;
X509_digest(xcert, EVP_sha1(), fp, &fp_len);
- fp_buffer = (char*) calloc(3, fp_len);
+ fp_buffer = (char*) calloc(fp_len, 3);
if (!fp_buffer)
return NULL;
num_subject_alt_names = sk_GENERAL_NAME_num(subject_alt_names);
if (num_subject_alt_names)
{
- strings = (char**) malloc(sizeof(char*) * num_subject_alt_names);
+ strings = (char**) calloc(num_subject_alt_names, sizeof(char*));
if (!strings)
goto out;
- *lengths = (int*) malloc(sizeof(int) * num_subject_alt_names);
+ *lengths = (int*) calloc(num_subject_alt_names, sizeof(int));
if (!*lengths)
{
free(strings);
const RDPGFX_CREATE_SURFACE_PDU* createSurface)
{
gdiGfxSurface* surface;
- rdpGdi* gdi = (rdpGdi*) context->custom;
+ rdpGdi* gdi = (rdpGdi*) context->custom;
surface = (gdiGfxSurface*) calloc(1, sizeof(gdiGfxSurface));
if (!surface)
cacheEntry->height = (UINT32)(rect->bottom - rect->top);
cacheEntry->format = surface->format;
cacheEntry->scanline = gfx_align_scanline(cacheEntry->width * 4, 16);
- cacheEntry->data = (BYTE*) calloc(1, cacheEntry->scanline * cacheEntry->height);
+ cacheEntry->data = (BYTE*) calloc(cacheEntry->height, cacheEntry->scanline);
if (!cacheEntry->data)
{
RDP_KEYBOARD_LAYOUT* new;
num = 0;
- layouts = (RDP_KEYBOARD_LAYOUT*) malloc((num + 1) * sizeof(RDP_KEYBOARD_LAYOUT));
+ layouts = (RDP_KEYBOARD_LAYOUT*) calloc((num + 1), sizeof(RDP_KEYBOARD_LAYOUT));
if (!layouts)
return NULL;
{
surface->scanline = (surface->width + (surface->width % 4)) * 4;
- surface->data = (BYTE*) malloc(surface->scanline * surface->height);
+ surface->data = (BYTE*) calloc(surface->height, surface->scanline);
if (!surface->data)
{
return 1;
scanline = width * 4;
- buffer = (BYTE*) malloc(scanline * height);
+ buffer = (BYTE*) calloc(height, scanline);
if (!buffer)
return 1;
/* Max */
fgets(line, sizeof(line), fp);
- if (!(rgb_data = malloc(context->icon_width * context->icon_height * 3)))
+ if (!(rgb_data = calloc(context->icon_height, context->icon_width * 3)))
goto out_fail;
for (i = 0; i < context->icon_width * context->icon_height * 3; i++)
}
/* background with same size, which will be used to erase the icon from old position */
- if (!(context->bg_data = malloc(context->icon_width * context->icon_height *
- 3)))
+ if (!(context->bg_data = calloc(context->icon_height, context->icon_width * 3)))
goto out_fail;
memset(context->bg_data, 0xA0, context->icon_width * context->icon_height * 3);
WLog_INFO(TAG, "Using sound ouput endpoint: [%s] (%s)", nameVar.pwszVal, pwszID);
//WLog_INFO(TAG, "matched %d characters", wcscmp(pattern, nameVar.pwszVal);
devStrLen = wcslen(pwszID);
- *deviceStr = (LPWSTR) calloc(1, (devStrLen * 2) + 2);
+ *deviceStr = (LPWSTR) calloc(devStrLen + 1, 2);
if (!deviceStr)
return -1;
wcscpy_s(*deviceStr, devStrLen+1, pwszID);
totalBitmapSize = 0;
bitmapUpdate.count = bitmapUpdate.number = rows * cols;
- if (!(bitmapData = (BITMAP_DATA*) malloc(sizeof(BITMAP_DATA) *
- bitmapUpdate.number)))
+ if (!(bitmapData = (BITMAP_DATA*) calloc(bitmapUpdate.number, sizeof(BITMAP_DATA))))
return FALSE;
bitmapUpdate.rectangles = bitmapData;
BITMAP_DATA* fragBitmapData = NULL;
if (k > 0)
- fragBitmapData = (BITMAP_DATA*) malloc(sizeof(BITMAP_DATA) * k);
+ fragBitmapData = (BITMAP_DATA*) calloc(k, sizeof(BITMAP_DATA));
if (!fragBitmapData)
{
encoder->maxTileHeight);
tileSize = encoder->maxTileWidth * encoder->maxTileHeight * 4;
tileCount = encoder->gridWidth * encoder->gridHeight;
- encoder->gridBuffer = (BYTE*) malloc(tileSize * tileCount);
+ encoder->gridBuffer = (BYTE*) calloc(tileSize, tileCount);
if (!encoder->gridBuffer)
return -1;
- encoder->grid = (BYTE**) malloc(tileCount * sizeof(BYTE*));
+ encoder->grid = (BYTE**) calloc(tileCount, sizeof(BYTE*));
if (!encoder->grid)
return -1;
surface->height = height;
surface->scanline = ALIGN_SCREEN_SIZE(surface->width, 4) * 4;
surface->format = PIXEL_FORMAT_BGRX32;
- surface->data = (BYTE*) calloc(1,
- surface->scanline * ALIGN_SCREEN_SIZE(surface->height, 4));
+ surface->data = (BYTE*) calloc(ALIGN_SCREEN_SIZE(surface->height, 4),
+ surface->scanline);
if (!surface->data)
{
if (!pFormatIds)
{
- pFormatIds = malloc(clipboard->numFormats * sizeof(UINT32));
+ pFormatIds = calloc(clipboard->numFormats, sizeof(UINT32));
if (!pFormatIds)
return 0;
if (!pFormatIds)
{
- pFormatIds = malloc(count * sizeof(UINT32));
+ pFormatIds = calloc(count, sizeof(UINT32));
if (!pFormatIds)
return 0;
return FALSE;
}
- pDcb = (DCB*)calloc(1, sizeof(DCB) * 2);
+ pDcb = (DCB*)calloc(2, sizeof(DCB));
if (!pDcb)
return FALSE;
pDcb->DCBlength = sizeof(DCB) * 2;
return -1;
}
- lpWideCharStr = (LPWSTR) malloc(cchWideChar * sizeof(WCHAR));
+ lpWideCharStr = (LPWSTR) calloc(cchWideChar, sizeof(WCHAR));
if (!lpWideCharStr)
{
printf("MultiByteToWideChar: unable to allocate memory for test\n");
if (status == 0)
return -1;
- pszNameString = (LPTSTR) malloc(status * sizeof(TCHAR));
+ pszNameString = (LPTSTR) calloc(status, sizeof(TCHAR));
if (!pszNameString)
{
printf("Unable to allocate memory\n");
}
/* SpnLength includes null terminator */
- Spn = (LPTSTR) malloc(SpnLength * sizeof(TCHAR));
+ Spn = (LPTSTR) calloc(SpnLength, sizeof(TCHAR));
if (!Spn)
{
_tprintf(_T("DsMakeSpn: Unable to allocate memroy\n"));
envp = environ;
cchEnvironmentBlock = 128;
- lpszEnvironmentBlock = (LPCH) malloc(cchEnvironmentBlock * sizeof(CHAR));
+ lpszEnvironmentBlock = (LPCH) calloc(cchEnvironmentBlock, sizeof(CHAR));
if (!lpszEnvironmentBlock)
return NULL;
offset = 0;
cchEnvironmentBlock = 128;
- lpszEnvironmentBlock = (LPCH) malloc(cchEnvironmentBlock * sizeof(CHAR));
+ lpszEnvironmentBlock = (LPCH) calloc(cchEnvironmentBlock, sizeof(CHAR));
if (!lpszEnvironmentBlock)
{
#ifdef UNICODE
length = MultiByteToWideChar(CP_UTF8, 0, str, strlen(str), NULL, 0);
- BasePath = (WCHAR*) malloc((length + 1) * sizeof(WCHAR));
+ BasePath = (WCHAR*) calloc((length + 1), sizeof(WCHAR));
if (!BasePath)
{
_tprintf(_T("Unable to allocate memory\n"));
#ifdef UNICODE
length = MultiByteToWideChar(CP_UTF8, 0, str, strlen(str), NULL, 0);
- BasePath = (WCHAR*) malloc((length + 1) * sizeof(WCHAR));
+ BasePath = (WCHAR*) calloc((length + 1), sizeof(WCHAR));
if (!BasePath)
{
_tprintf(_T("Unable to allocate memory"));
if (SourceString->MaximumLength)
{
- if (!(wbuf = (PWSTR) malloc(SourceString->MaximumLength * 2)))
+ if (!(wbuf = (PWSTR) calloc(SourceString->MaximumLength, 2)))
return STATUS_NO_MEMORY;
}
BOOL allReaders = FALSE;
p = (char*) names;
cchReaders = *pcchReaders;
- namesWinSCard = (char*) malloc(cchReaders * 2);
+ namesWinSCard = (char*) calloc(cchReaders, 2);
if (!namesWinSCard)
return NULL;
DWORD cchReaders;
p = (char*) names;
cchReaders = *pcchReaders;
- namesPCSC = (char*) malloc(cchReaders * 2);
+ namesPCSC = (char*) calloc(cchReaders, 2);
if (!namesPCSC)
return NULL;
if (identity->UserLength > 0)
{
- identity->User = (UINT16*) malloc((identity->UserLength + 1) * sizeof(WCHAR));
+ identity->User = (UINT16*) calloc((identity->UserLength + 1), sizeof(WCHAR));
if (!identity->User)
return -1;
if (identity->DomainLength > 0)
{
- identity->Domain = (UINT16*) malloc((identity->DomainLength + 1) * sizeof(WCHAR));
+ identity->Domain = (UINT16*) calloc((identity->DomainLength + 1), sizeof(WCHAR));
if (!identity->Domain)
return -1;
if (srcIdentity->Password)
{
- identity->Password = (UINT16*) malloc((identity->PasswordLength + 1) * sizeof(WCHAR));
+ identity->Password = (UINT16*) calloc((identity->PasswordLength + 1), sizeof(WCHAR));
if (!identity->Password)
return -1;
numArgs = 0;
lpEscapedCmdLine = NULL;
cmdLineLength = (int) strlen(lpCmdLine);
- lpEscapedChars = (BOOL*) calloc(1, (cmdLineLength + 1) * sizeof(BOOL));
+ lpEscapedChars = (BOOL*) calloc(cmdLineLength + 1, sizeof(BOOL));
if (!lpEscapedChars)
return NULL;
{
int i, n;
char* pLastEnd = NULL;
- lpEscapedCmdLine = (char*) malloc((cmdLineLength + 1) * sizeof(char));
+ lpEscapedCmdLine = (char*) calloc(cmdLineLength + 1, sizeof(char));
if (!lpEscapedCmdLine)
{
arrayList->capacity = 32;
arrayList->growthFactor = 2;
arrayList->object.fnObjectEquals = ArrayList_DefaultCompare;
- arrayList->array = (void **)malloc(arrayList->capacity * sizeof(void *));
+ arrayList->array = (void **)calloc(arrayList->capacity, sizeof(void *));
if (!arrayList->array)
goto out_free;
pool->size = 0;
pool->capacity = 32;
- pool->array = (void**) malloc(sizeof(void*) * pool->capacity);
+ pool->array = (void**) calloc(pool->capacity, sizeof(void*));
if (!pool->array)
goto out_error;
}
pool->aSize = 0;
pool->aCapacity = 32;
- pool->aArray = (wBufferPoolItem*) malloc(sizeof(wBufferPoolItem) * pool->aCapacity);
+ pool->aArray = (wBufferPoolItem*) calloc(pool->aCapacity, sizeof(wBufferPoolItem));
if (!pool->aArray)
goto out_error;
pool->uSize = 0;
pool->uCapacity = 32;
- pool->uArray = (wBufferPoolItem*) malloc(sizeof(wBufferPoolItem) * pool->uCapacity);
+ pool->uArray = (wBufferPoolItem*) calloc(pool->uCapacity, sizeof(wBufferPoolItem));
if (!pool->uArray)
{
free(pool->aArray);
{
pool->capacity = 32;
pool->size = 0;
- pool->array = (void**) malloc(sizeof(void*) * pool->capacity);
+ pool->array = (void**) calloc(pool->capacity, sizeof(void*));
if (!pool->array)
{
free(pool);
pubSub->count = 0;
pubSub->size = 64;
- pubSub->events = (wEventType*) calloc(1, sizeof(wEventType) * pubSub->size);
+ pubSub->events = (wEventType*) calloc(pubSub->size, sizeof(wEventType));
if (!pubSub->events)
{
if (pubSub->synchronized)
stack->synchronized = synchronized;
stack->capacity = 32;
- stack->array = (void**) malloc(sizeof(void*) * stack->capacity);
+ stack->array = (void**) calloc(stack->capacity, sizeof(void*));
if (!stack->array)
goto out_free;
size_t array_size = data->used * sizeof(char*);
size_t lines_size = data->used * line_len;
char **vlines = calloc(1, array_size + lines_size);
- SYMBOL_INFO* symbol = calloc(sizeof(SYMBOL_INFO) + line_len * sizeof(char), 1);
+ SYMBOL_INFO* symbol = calloc(1, sizeof(SYMBOL_INFO) + line_len * sizeof(char));
IMAGEHLP_LINE64* line = (IMAGEHLP_LINE64*) calloc(1, sizeof(IMAGEHLP_LINE64));
if (!vlines || !symbol || !line)
section->nKeys = 0;
section->cKeys = 64;
- section->keys = (wIniFileKey**) malloc(sizeof(wIniFileKey*) * section->cKeys);
+ section->keys = (wIniFileKey**) calloc(section->cKeys, sizeof(wIniFileKey*));
if (!section->keys)
{
For every symbol, maxbitlen coins will be created*/
coinmem = numpresent * 2; /*max amount of coins needed with the current algo*/
- coins = (Coin*)malloc(sizeof(Coin) * coinmem);
- prev_row = (Coin*)malloc(sizeof(Coin) * coinmem);
+ coins = (Coin*)calloc(sizeof(Coin), coinmem);
+ prev_row = (Coin*)calloc(sizeof(Coin), coinmem);
if(!coins || !prev_row)
{
free(coins);
static unsigned hash_init(Hash* hash, unsigned windowsize)
{
unsigned i;
- hash->head = (int*)malloc(sizeof(int) * HASH_NUM_VALUES);
- hash->val = (int*)malloc(sizeof(int) * windowsize);
- hash->chain = (unsigned short*)malloc(sizeof(unsigned short) * windowsize);
+ hash->head = (int*)calloc(sizeof(int), HASH_NUM_VALUES);
+ hash->val = (int*)calloc(sizeof(int), windowsize);
+ hash->chain = (unsigned short*)calloc(sizeof(unsigned short), windowsize);
- hash->zeros = (unsigned short*)malloc(sizeof(unsigned short) * windowsize);
- hash->headz = (int*)malloc(sizeof(int) * (MAX_SUPPORTED_DEFLATE_LENGTH + 1));
- hash->chainz = (unsigned short*)malloc(sizeof(unsigned short) * windowsize);
+ hash->zeros = (unsigned short*)calloc(sizeof(unsigned short), windowsize);
+ hash->headz = (int*)calloc(sizeof(int), (MAX_SUPPORTED_DEFLATE_LENGTH + 1));
+ hash->chainz = (unsigned short*)calloc(sizeof(unsigned short), windowsize);
if(!hash->head || !hash->chain || !hash->val || !hash->headz|| !hash->chainz || !hash->zeros)
{
{
LPWSTR PasswordW = NULL;
- if (!(PasswordW = (LPWSTR) malloc(PasswordLength * 2)))
+ if (!(PasswordW = (LPWSTR) calloc(PasswordLength, 2)))
return NULL;
MultiByteToWideChar(CP_ACP, 0, Password, PasswordLength, PasswordW, PasswordLength);
LPWSTR DomainW = NULL;
LPWSTR PasswordW = NULL;
- UserW = (LPWSTR) malloc(UserLength * 2);
- DomainW = (LPWSTR) malloc(DomainLength * 2);
- PasswordW = (LPWSTR) malloc(PasswordLength * 2);
+ UserW = (LPWSTR) calloc(UserLength, 2);
+ DomainW = (LPWSTR) calloc(DomainLength, 2);
+ PasswordW = (LPWSTR) calloc(PasswordLength, 2);
if (!UserW || !DomainW || !PasswordW)
goto out_fail;
LPWSTR UserW = NULL;
LPWSTR DomainW = NULL;
- UserW = (LPWSTR) malloc(UserLength * 2);
- DomainW = (LPWSTR) malloc(DomainLength * 2);
+ UserW = (LPWSTR) calloc(UserLength, 2);
+ DomainW = (LPWSTR) calloc(DomainLength, 2);
if (!UserW || !DomainW)
goto out_fail;
GetLastError() != ERROR_MORE_DATA)
goto fallback;
- computerName = (CHAR*)calloc(nSize, 1);
+ computerName = (CHAR*)calloc(1, nSize);
if (!computerName)
goto fallback;
GetLastError() != ERROR_MORE_DATA)
return NULL;
- computerName = (CHAR*)calloc(nSize, 1);
+ computerName = (CHAR*)calloc(1, nSize);
if (!computerName)
return NULL;