Changeset 563


Ignore:
Timestamp:
Apr 30, 2011, 12:49:15 AM (6 years ago)
Author:
Sam Hocevar
Message:

lisp: minor refactoring.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • abuse/trunk/src/lisp/lisp.cpp

    r561 r563  
    280280LFixedPoint *LFixedPoint::Create(int32_t x)
    281281{
    282     size_t size = sizeof(LFixedPoint);
    283     if (size < sizeof(LRedirect))
    284         size = sizeof(LRedirect);
     282    size_t size = Max(sizeof(LFixedPoint), sizeof(LRedirect));
    285283
    286284    LFixedPoint *p = (LFixedPoint *)lmalloc(size, current_space);
     
    292290LObjectVar *LObjectVar::Create(int index)
    293291{
    294     size_t size = sizeof(LObjectVar);
    295     if (size < sizeof(LRedirect))
    296         size = sizeof(LRedirect);
     292    size_t size = Max(sizeof(LObjectVar), sizeof(LRedirect));
    297293
    298294    LObjectVar *p = (LObjectVar *)lmalloc(size, current_space);
     
    306302    if (addr == NULL)
    307303        return NULL;
    308     size_t size = sizeof(LPointer);
    309     if (size < sizeof(LRedirect))
    310         size = sizeof(LRedirect);
     304    size_t size = Max(sizeof(LPointer), sizeof(LRedirect));
    311305
    312306    LPointer *p = (LPointer *)lmalloc(size, current_space);
     
    318312LChar *LChar::Create(uint16_t ch)
    319313{
    320     size_t size = sizeof(LChar);
    321     if (size < sizeof(LRedirect))
    322         size = sizeof(LRedirect);
     314    size_t size = Max(sizeof(LChar), sizeof(LRedirect));
    323315
    324316    LChar *c = (LChar *)lmalloc(size, current_space);
     
    345337struct LString *LString::Create(int length)
    346338{
    347     size_t size = sizeof(LString) + length - 1;
    348     if (size < sizeof(LRedirect))
    349         size = sizeof(LRedirect);
     339    size_t size = Max(sizeof(LString) + length - 1, sizeof(LRedirect));
    350340
    351341    LString *s = (LString *)lmalloc(size, current_space);
     
    359349    PtrRef r1(arg_list), r2(block_list);
    360350
    361     size_t size = sizeof(LUserFunction);
    362     if (size < sizeof(LRedirect))
    363         size = sizeof(LRedirect);
     351    size_t size = Max(sizeof(LUserFunction), sizeof(LRedirect));
    364352
    365353    LUserFunction *lu = (LUserFunction *)lmalloc(size, current_space);
     
    372360LSysFunction *new_lisp_sys_function(int min_args, int max_args, int fun_number)
    373361{
    374     size_t size = sizeof(LSysFunction);
    375     if (size < sizeof(LRedirect))
    376         size = sizeof(LRedirect);
     362    size_t size = Max(sizeof(LSysFunction), sizeof(LRedirect));
    377363
    378364    // System functions should reside in permanant space
     
    409395LSymbol *new_lisp_symbol(char *name)
    410396{
    411     size_t size = sizeof(LSymbol);
    412     if (size < sizeof(LRedirect))
    413         size = sizeof(LRedirect);
     397    size_t size = Max(sizeof(LSymbol), sizeof(LRedirect));
    414398
    415399    LSymbol *s = (LSymbol *)lmalloc(size, current_space);
     400    PtrRef ref(s);
     401
    416402    s->type = L_SYMBOL;
    417403    s->name = LString::Create(name);
     
    426412LNumber *LNumber::Create(long num)
    427413{
    428     size_t size = sizeof(LNumber);
    429     if (size < sizeof(LRedirect))
    430         size = sizeof(LRedirect);
     414    size_t size = Max(sizeof(LNumber), sizeof(LRedirect));
    431415
    432416    LNumber *n = (LNumber *)lmalloc(size, current_space);
     
    438422LList *LList::Create()
    439423{
    440     size_t size = sizeof(LList);
    441     if (size < sizeof(LRedirect))
    442         size = sizeof(LRedirect);
     424    size_t size = Max(sizeof(LList), sizeof(LRedirect));
    443425
    444426    LList *c = (LList *)lmalloc(size, current_space);
Note: See TracChangeset for help on using the changeset viewer.