itss: Replace malloc() with HeapAlloc()

Vitaliy Margolen wine-devel at kievinfo.com
Wed Feb 11 20:50:06 CST 2009


Francois Gouget wrote:
> On Tue, 10 Feb 2009, Andrew Talbot wrote:
> [...]
>> There are also many calls to realloc() - a function with complexities of its
>> own - and other functions with "realloc" in their name.
> 
> Good point. Here are the ones I noticed:
> 
> dlls/rsaenh/mpi.c:3668:    if ((tmp = realloc (a->dp, sizeof (mp_digit) * a->used)) == NULL) {
> dlls/rsaenh/mpi.c:72:    tmp = realloc (a->dp, sizeof (mp_digit) * size);
> dlls/twain_32/dsm_ctrl.c:87:			devices = realloc(devices, sizeof(devices[0])*(nrdevices+1));
> 
> dlls/advapi32/tests/registry.c:55:    if ((ret = realloc( list[idx], size ))) list[idx] = ret;
> dlls/ddraw/tests/ddrawmodes.c:97:	    modes = realloc(modes, (modes_size *= 2) * sizeof(DDSURFACEDESC));
> dlls/mstask/tests/task.c:41:    if ((ret = realloc(list[idx], size)))
> dlls/oleaut32/tests/tmarshal.c:59:    if ((ret = realloc( list[idx], size ))) list[idx] = ret;
> dlls/userenv/tests/userenv.c:54:    if ((ret = realloc( list[idx], size ))) list[idx] = ret;
> 
> And we even have two calls to calloc()!
> dlls/winedos/int33.c:267:    MCALLDATA *data = calloc(1,sizeof(MCALLDATA));
> dlls/winedos/devices.c:137:    hdr_ptr = calloc(1,sizeof(void *)+extra);
> 
> 
> 
Don't forget few places with strdup:

dlls/gphoto2.ds/gphoto2_main.c:70:      gpfile->folder = strdup(folder);
dlls/gphoto2.ds/gphoto2_main.c:71:      gpfile->filename = strdup(name);
dlls/twain_32/dsm_ctrl.c:90:            devices[nrdevices].modname = strdup(dsname);
dlls/wineps.drv/mkagl.c:141:    glyphs[num_glyphs].name = strdup(namebuf);
dlls/wineps.drv/mkagl.c:142:    glyphs[num_glyphs].comment = strdup(commbuf);
dlls/wineps.drv/mkagl.c:280:        glyphs[num_glyphs].name = strdup(namebuf);
dlls/wineps.drv/mkagl.c:281:        glyphs[num_glyphs].comment = strdup(linebuf);
dlls/winex11.drv/opengl.c:320:    WineGLInfo.glExtensions = strdup((const char *) pglGetString(GL_EXTENSIONS));

Vitaliy.



More information about the wine-devel mailing list