⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lls_blob.c

📁 国外网站上的一些精典的C程序
💻 C
字号:
/* =======================================================================    LLS_BLOB.c      Generic Singly Linked Lists for Binary Large OBjects.                    Linked Lists for variable size data-items.                    This is a 'front end' for the generic LLS module.                    v1.00  94-08-11 _____              This version is Public Domain. /_|__|             A.Reitsma, Delft, The Netherlands./  | \  --------------------------------------------------------------- */#include "ll_defs.h"#include "lls.h"            /* the generic LLS functions ...            */#include "lls_blob.h"       /* also includes extkword.h if necessary    */struct BlobDesc{    void * data ;           /* 'data' can be obtained by LLSnodePtr() ! */    unsigned size ;};#define ERR_MEMORY          -1/* ---- LL blob system management ------------------------------------- */int LLSblobCreate( void ){    return LLScreate( sizeof( struct BlobDesc ));}/* ---- LL blob node management --------------------------------------- */int LLSblobInsert( int List, void * Source, unsigned Size ){                                       /* insert _BEFORE_ current node */    struct BlobDesc Blob ;    Blob.size = Size ;    Blob.data = malloc( Size );    if( NULL == Blob.data )    {        return ERR_MEMORY ;    }    memcpy( Blob.data, Source, Size );    LLSnodeInsertFrom( List, & Blob );    return LIST_NO_PROBLEMS ;}int LLSblobAdd( int List, void * Source, unsigned Size ){                                        /* insert _AFTER_ current node */    struct BlobDesc Blob ;    Blob.size = Size ;    Blob.data = malloc( Size );    if( NULL == Blob.data )    {        return ERR_MEMORY ;    }    memcpy( Blob.data, Source, Size );    LLSnodeAddFrom( List, & Blob );    return LIST_NO_PROBLEMS ;}int LLSblobPrepend( int List, void * Source, unsigned Size ){                                               /* insert as first node */    struct BlobDesc Blob ;    Blob.size = Size ;    Blob.data = malloc( Size );    if( NULL == Blob.data )    {        return ERR_MEMORY ;    }    memcpy( Blob.data, Source, Size );    LLSnodePrependFrom( List, & Blob );    return LIST_NO_PROBLEMS ;}int LLSblobAppend( int List, void * Source, unsigned Size ){                                                /* insert as last node */    struct BlobDesc Blob ;    Blob.size = Size ;    Blob.data = malloc( Size );    if( NULL == Blob.data )    {        return ERR_MEMORY ;    }    memcpy( Blob.data, Source, Size );    LLSnodeAppendFrom( List, & Blob );    return LIST_NO_PROBLEMS ;}void LLSblobDelete( int List ){    struct BlobDesc Blob ;    LLSnodeDataTo( List, & Blob );    free( Blob.data );    LLSnodeDelete( List );    return ;}/* ---- stored data management ---------------------------------------- */unsigned LLSblobData( int List, void * Destination ){    struct BlobDesc Blob ;    LLSnodeDataTo( List, & Blob );    if( NULL != Destination )        memcpy( Destination, Blob.data, Blob.size );    return Blob.size ;       /* size needed for blob */}/* ==== LLS_BLOB.c  end =============================================== */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -