mirror of
https://github.com/netsurf-browser/netsurf
synced 2024-12-16 09:12:44 +03:00
Use a function to create ready-cleared memory
This commit is contained in:
parent
3630d7348d
commit
80558b3116
@ -16,7 +16,7 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
|
||||
@ -238,7 +238,7 @@ STATIC VOID rx_open(struct ARexxCmd *cmd, struct RexxMsg *rxm __attribute__((unu
|
||||
{
|
||||
if(!gw) return;
|
||||
|
||||
dln = AllocVecTags(sizeof(struct dlnode), AVT_ClearWithValue, 0, TAG_DONE);
|
||||
dln = ami_misc_allocvec_clear(sizeof(struct dlnode), 0);
|
||||
dln->filename = strdup((char *)cmd->ac_ArgList[3]);
|
||||
dln->node.ln_Name = strdup((char *)cmd->ac_ArgList[0]);
|
||||
dln->node.ln_Type = NT_USER;
|
||||
|
@ -40,6 +40,7 @@
|
||||
#include "amiga/gui.h"
|
||||
#include "amiga/bitmap.h"
|
||||
#include "amiga/download.h"
|
||||
#include "amiga/misc.h"
|
||||
|
||||
/**
|
||||
* Create a bitmap.
|
||||
@ -54,13 +55,10 @@ void *bitmap_create(int width, int height, unsigned int state)
|
||||
{
|
||||
struct bitmap *bitmap;
|
||||
|
||||
bitmap = AllocVecTags(sizeof(struct bitmap), AVT_ClearWithValue, 0, TAG_DONE);
|
||||
bitmap = ami_misc_allocvec_clear(sizeof(struct bitmap), 0);
|
||||
if(bitmap)
|
||||
{
|
||||
bitmap->pixdata = AllocVecTags(width*height*4,
|
||||
AVT_Type,MEMF_PRIVATE,
|
||||
AVT_ClearWithValue,0xff,
|
||||
TAG_DONE);
|
||||
bitmap->pixdata = ami_misc_allocvec_clear(width*height*4, 0xff);
|
||||
bitmap->width = width;
|
||||
bitmap->height = height;
|
||||
|
||||
@ -378,7 +376,7 @@ struct bitmap *ami_bitmap_from_datatype(char *filename)
|
||||
bm_format, bitmap_get_rowstride(bm), 0, 0,
|
||||
bmh->bmh_Width, bmh->bmh_Height);
|
||||
#ifndef __amigaos4__
|
||||
ami_bitmap_argb_to_rgba(bitmap);
|
||||
ami_bitmap_argb_to_rgba(bm);
|
||||
#endif
|
||||
bitmap_set_opaque(bm, bitmap_test_opaque(bm));
|
||||
}
|
||||
|
@ -42,6 +42,7 @@
|
||||
#include "amiga/iff_cset.h"
|
||||
#include "amiga/iff_dr2d.h"
|
||||
#include "amiga/menu.h"
|
||||
#include "amiga/misc.h"
|
||||
#include "amiga/utf8.h"
|
||||
|
||||
#define ID_UTF8 MAKE_ID('U','T','F','8')
|
||||
@ -110,10 +111,10 @@ static char *ami_clipboard_cat_collection(struct CollectionItem *ci, LONG codese
|
||||
|
||||
case 0:
|
||||
if(ci_new) {
|
||||
ci_next->ci_Next = AllocVecTags(sizeof(struct CollectionItem), AVT_ClearWithValue, 0, TAG_DONE);
|
||||
ci_next->ci_Next = ami_misc_allocvec_clear(sizeof(struct CollectionItem), 0);
|
||||
ci_next = ci_next->ci_Next;
|
||||
} else {
|
||||
ci_new = AllocVecTags(sizeof(struct CollectionItem), AVT_ClearWithValue, 0, TAG_DONE);
|
||||
ci_new = ami_misc_allocvec_clear(sizeof(struct CollectionItem), 0);
|
||||
ci_next = ci_new;
|
||||
}
|
||||
|
||||
@ -124,10 +125,10 @@ static char *ami_clipboard_cat_collection(struct CollectionItem *ci, LONG codese
|
||||
|
||||
default:
|
||||
if(ci_new) {
|
||||
ci_next->ci_Next = AllocVecTags(sizeof(struct CollectionItem), AVT_ClearWithValue, 0, TAG_DONE);
|
||||
ci_next->ci_Next = ami_misc_allocvec_clear(sizeof(struct CollectionItem), 0);
|
||||
ci_next = ci_next->ci_Next;
|
||||
} else {
|
||||
ci_new = AllocVecTags(sizeof(struct CollectionItem), AVT_ClearWithValue, 0, TAG_DONE);
|
||||
ci_new = ami_misc_allocvec_clear(sizeof(struct CollectionItem), 0);
|
||||
ci_next = ci_new;
|
||||
}
|
||||
|
||||
|
13
amiga/misc.c
13
amiga/misc.c
@ -34,6 +34,19 @@
|
||||
#include "amiga/misc.h"
|
||||
#include "amiga/utf8.h"
|
||||
|
||||
void *ami_misc_allocvec_clear(int size, UBYTE value)
|
||||
{
|
||||
#ifdef __amigaos4__
|
||||
return AllocVecTags(size, AVT_ClearWithValue, value, TAG_DONE);
|
||||
#else
|
||||
void *mem = AllocVec(size, MEMF_CLEAR);
|
||||
if (mem && (value != 0)) {
|
||||
memset(mem, value, size);
|
||||
}
|
||||
return mem;
|
||||
#endif
|
||||
}
|
||||
|
||||
static LONG ami_misc_req(const char *message, uint32 type)
|
||||
{
|
||||
LONG ret = 0;
|
||||
|
@ -23,6 +23,7 @@
|
||||
extern struct gui_file_table *amiga_file_table;
|
||||
struct Window;
|
||||
|
||||
void *ami_misc_allocvec_clear(int size, UBYTE value);
|
||||
char *translate_escape_chars(const char *s);
|
||||
void ami_misc_fatal_error(const char *message);
|
||||
int32 ami_warn_user_multi(const char *body,
|
||||
|
@ -36,6 +36,9 @@
|
||||
#include <exec/memory.h>
|
||||
#endif
|
||||
|
||||
/* Macros */
|
||||
#define IsMinListEmpty(L) (L)->mlh_Head->mln_Succ == 0
|
||||
|
||||
/* Define extra memory type flags */
|
||||
#define MEMF_PRIVATE MEMF_ANY
|
||||
#define MEMF_SHARED MEMF_ANY
|
||||
@ -57,8 +60,8 @@
|
||||
#define ObtainCharsetInfo(A,B,C) (const char *)"ISO-8859-1"
|
||||
|
||||
/* DOS */
|
||||
#define FOpen(A,B,C) Open(A,B);
|
||||
#define FClose(A) Close(A);
|
||||
#define FOpen(A,B,C) Open(A,B)
|
||||
#define FClose(A) Close(A)
|
||||
|
||||
/* Intuition */
|
||||
#define IDoMethod DoMethod
|
||||
|
Loading…
Reference in New Issue
Block a user